How to get the value of an ASP.net variable into a javascript textbox
<p>I'm writing some Javascript code for an ASP.net page.</p>

<p>I have the string "foo" assigned to a string variable <code>myString</code>.</p>

<p>I would like to assign the value of <code>myString</code> to a JavaScript variable, so I write in my ASP.net code:</p>

<pre><code>&lt;script type='txt/javascript' language='javascript'&gt;
    var stringFromDotNet = '&lt;%=myString%&gt;';
&lt;/script&gt;
</code></pre>

<p>This works fine as long as <code>myString</code> does not contain quotation marks or line-breaks, but as as soon as I try to assign something with quotation marks or line-breaks, all hell breaks loose and my code doesn't work.  As a matter of fact, I can see that this code is vulnerable to all sort of injection attacks.</p>

<p>So... What can I do get the value of <code>myString</code> assigned to a variable in JavaScript?</p>

<p><i>Update</i>:  I've tried creating a page with just an ASP:Hidden field.  It looks like the values inside are html encoded.</p>
