Skip to content Skip to sidebar Skip to footer

Removing Scripts Added By Clientscript.registerstartupscript

In my application's login control, I am showing a dialog window if the login failed. In this way: protected void EMSLogin_Authenticate(object sender, AuthenticateEventArgs e) {

Solution 1:

Try calling the function:

ClientScript.RegisterStartupScript(typeof(ScriptManager), "CallShowDialog", "", true);

...in the Page_Load event handler.

Page_Load occurs before the button click event handler. You can verify this by adding the following code and looking in the debug/output window:

protectedvoidPage_Load(object sender, EventArgs e)
{
    System.Diagnostics.Debug.WriteLine("Page_Load");   
}

protectedvoidButton1_Click(object sender, EventArgs e)
{
    System.Diagnostics.Debug.WriteLine("Button1_Click");      
}

So erasing the script in the Page_Load event handler should clear any previous script that was loaded.

Post a Comment for "Removing Scripts Added By Clientscript.registerstartupscript"