Initializing JavaScript Variables on Server Side
<p>I am having problems setting JavaScript variables on the Server Side in ASP.Net Web Forms (Not MVC) using Master Pages.</p>

<p>Basically I want to do something like this:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    var z = '&lt;%# Request.QueryString["Env"] %&gt;';
&lt;/script&gt;
</code></pre>

<p>After I run the code I see:  var z=’’;</p>

<p>I also tried: </p>

<p>var z = '&lt;%= Request.QueryString["Env"] %>';</p>

<p>After I run that code I get the following error so I assume that is not correct:</p>

<p>The Controls collection cannot be modified because the control contains code blocks (i.e. &lt;% ... %>).</p>

<p>I have been doing mainly MVC development these past few years so I am not sure what I am doing wrong.</p>

<p>Please let me know. </p>

<p>Thanks</p>
