title: asp.net c# javascript The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
body: <p>I am using Asp.net c# with javascript <br>
  I want use the Session value in javascript so am using this code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var Warehousename = '&lt;%= Session["warehouse_id"] %&gt;';
      var temp = new Array();
      temp = Warehousename.split(",");
      if (temp.length &gt; 1) {
          alert('you have multiple access of warehouse. Kindly select the only one warehouse from Preference')
          window.location.href = "frm_preferences.aspx";
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>But am facing some error like </p>
  
  <blockquote>
    <p>'The Controls collection cannot be modified because the control
    contains code blocks (i.e. &lt;% ... %>).'</p>
  </blockquote>
  
  <p>So where am doing wrong please suggest me</p>