title: Asp.net RegisterStartupScript not firing
body: <p>In my asp.net application, I am trying to call a <code>Javascript</code> function, by doing the following:</p>
  
  <pre><code>Page.ClientScript.RegisterStartupScript(this.GetType(), "goToDiv", "function goToDiv(){window.location.hash = '#ctl00_body_ApplicationFormContainer'};", true);        
  </code></pre>
  
  <p>But it is not firing.</p>
  
  <p>The <code>JavaScript</code> function is being called after a postback event, but I think it should still fire, as I added the following code to my <code>Page_Load</code>:</p>
  
  <pre><code>if (IsPostBack)
      {
          Response.Write("POSTBACK:" + DateTime.Now.ToString("hh.mm.ss.ffffff"));            
      }
  </code></pre>
  
  <p>and changed the startupscript to:</p>
  
  <pre><code>Page.ClientScript.RegisterStartupScript(this.GetType(), "goToDiv", "alert('POSTBACK: "+DateTime.Now.ToString("hh.mm.ss.ffffff")+"')", true);         
  </code></pre>
  
  <p>and the <code>JavaScript</code> alert time was after the postback time, telling me the <code>JavaScript</code> alert is fired after the postback?</p>
  
  <p>I then changed the code back and went to the sources tab in the console, before the startup script had been run, and entered:</p>
  
  <pre><code>goToDiv()
  </code></pre>
  
  <p>which gave the following error:</p>
  
  <pre><code>Uncaught ReferenceError: goToDiv is not defined(…)
  </code></pre>
  
  <p>eg the function does not exist.</p>
  
  <p>I then entered it again, after the startup script event, and it ran, so I know the function is created - so why is it not running?</p>
  
  <p>My code seems to be syntactically correct, so I cannot see what the problem is?</p>