title: Removing scripts added by ClientScript.RegisterStartupScript
body: <p>In my application's login control, I am showing a dialog window if the login failed. In this way:</p>
  
  <pre><code>protected void EMSLogin_Authenticate(object sender, AuthenticateEventArgs e) {
      log.Info("=============INSIDE EMSLogin_Authenticate======");
      RadTextBox UserName = EMSLogin.FindControl("UserName") as RadTextBox;
      RadTextBox Password = EMSLogin.FindControl("Password") as RadTextBox;
  
      if (Membership.ValidateUser(UserName.Text, Password.Text)) {
          FormsAuthentication.RedirectFromLoginPage(UserName.Text, false);
      } else {
          ClientScript.RegisterStartupScript(typeof(ScriptManager), "CallShowDialog", "showDialog();", true);         
      }
  }
  </code></pre>
  
  <p>The JavaScript is:</p>
  
  <pre><code>function showDialog() {
      $(document).ready(function () {
          $(".jym").dialog("open");
      });
  }
  </code></pre>
  
  <p>Now if the login failed the dialog is showing. But The problem is if I refresh the browser window, after one login failed, the dialog again opened, since the <code>$(".jym").dialog("open")</code> is written in the page. Then I have tried </p>
  
  <pre><code>protected void Page_Unload(object sender, EventArgs e) {        
      log.Info("=============INSIDE Page_Unload======");
      ClientScript.RegisterStartupScript(typeof(ScriptManager), "CallShowDialog", "", true);
  }
  </code></pre>
  
  <p>But no luck.</p>
  
  <p>Is there any way to solve this problem?</p>
  
  <hr>
  
  <p>If I use <code>ClientScript.RegisterClientScriptBlock()</code> this not working, I mean the dialog is not opening on error.</p>