Is there automatic formatting for an asp:literal control?
<p>Is there a way to automatically format a <code>string</code> for literal insertion into JavaScript code?</p>

<p>Say you have this in your page:</p>

<pre class="lang-html prettyprint-override"><code>&lt;script type="text/javascript"&gt;
    var strvar = &lt;asp:Literal runat="server" id="ltrStrvar"&gt;&lt;/asp:Literal&gt;;
&lt;/script&gt;
</code></pre>

<p>And in your server-side code:</p>

<pre class="lang-csharp prettyprint-override"><code>protected void Page_Load(object sender, EventArgs e) {
    ltrStrvar.Text = "hello \"world\"";
}
</code></pre>

<p>Is there a way to <em>automatically</em> have it escape the string and surround it with quotes for error-free insertion into JavaScript, so all I have to do is set the <code>Text</code> property with an arbitrary string? I know how to do it <em>manually</em> but was looking for a more elegant solution.</p>
