title: Web forms: body onload event can't find a Javascript function
body: <p>I come from MVC background and I have little experience with web forms.</p>
  <p>I have established where the problem is, but so far I have been unable to fix this.</p>
  <p>I have a form which is meant to execute Javascript function when body of the form loads. Please notice that head tag has a run at server attribute as it needs to use <code>Request.QueryString</code>.</p>
  <p>The code is below:</p>
  <pre><code>&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
  &lt;head runat=&quot;server&quot;&gt;
      
  &lt;script type=&quot;text/javascript&quot;&gt;
  
      function doSomething()
      {
          // Use web forms to do something
          var foo = &lt;%= Request.QueryString[&quot;input&quot;] %&gt;;
      }
      
  &lt;/script&gt;
  &lt;title&gt;Foo&lt;/title&gt;
  &lt;/head&gt;
  &lt;body onload=&quot;doSomething()&quot;&gt;
      &lt;form id=&quot;MainForm&quot; runat=&quot;server&quot;&gt;
      &lt;table width=&quot;272px&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;
          &lt;tr&gt;
              &lt;td class=&quot;body&quot;&gt;
                  ...
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>I get the following error:</p>
  <p>SCRIPT5007: The value of the property <code>doSomething</code> is null or undefined, not a Function object.</p>
  <p>My guess is that something executes on a server or other way round. This has worked previously (over a year ago), so potentially something in a web config was overwritten. I have spent the most of day on this and had no luck so far.</p>
  <p>Edit: Generated output is below</p>
  <pre><code>&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
  &lt;head&gt;
      
  &lt;script type=&quot;text/javascript&quot;&gt;
  
      function doSomething()
      {
          debugger;                 
          var o = crmForm.queryString;    
      }
      
  &lt;/script&gt;
  
  
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body onload=&quot;doSomething()&quot;&gt;
      &lt;form name=&quot;MainForm&quot; method=&quot;post&quot; action=&quot;fooPage.aspx?input=queryString&quot; id=&quot;MainForm&quot;&gt;
  &lt;div&gt;
  // hidden fields
      &lt;table width=&quot;272px&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;
          &lt;tr&gt;
              &lt;td class=&quot;body&quot;&gt;
                  // inputs
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
      
  
  
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>