title: calling ScriptManager.RegisterStartupScript from ASP.net
body: <p>I have a problem with calling a javascript Function from ASP.net;
  all the samples I have seen are in Button click Event,
  but I want to check something in Page_load and if the result was FALSE, show the user an alert and Redirect to another page. I tried these codes , but none of them runed, and the page redirected without any alert</p>
  <p>1.</p>
  <pre><code>protected void Page_PreRender(object sender, EventArgs e)
  {
      ScriptManager.RegisterStartupScript(this, GetType(), &quot;YourUniqueScriptKey&quot;, 
      &quot;alert('my message');&quot;, true);
  }
  </code></pre>
  <ol start="2">
  <li></li>
  </ol>
  <pre><code>   protected void Page_Load(object sender, EventArgs e)
      {
      ScriptManager.RegisterStartupScript(this.Page, this.GetType(), &quot;Alert&quot;,&quot;alert('my message');&quot;, true);
                      Response.Redirect(&quot;~/register.aspx&quot;, false);
                      return;
    }
  </code></pre>
  <p>I also tried <code>ScriptManager.RegisterClientScriptBlock</code>, but it had not worked.</p>