I have a JavaScript alert popup in my .NET application and it works locally and for most users on production. But some users are complaining that it doesn't work for them on all browsers (Firefox, Chrome and IE). They are not seeing the popup on click of the button nor do they see any error. What could be the issue?
Below is the code snippet for reference -
.aspx code
<asp:Button ID="btnSubmit" runat="server" Text="Submit Registration" OnClick="btnSubmit_Click" />
.aspx.cs code
protected void btnSubmit_Click(object sender, EventArgs e)
{
ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "Registration Submitted", "alert('Your registration has been successfully submitted.'); window.location='Registration.aspx'", true);
}
I had the same problem, if you run the Page.RegisterStartupScript method instead of the RegisterClientScriptBlock method, it will be fixed.
Page.RegisterStartupScript((sender as Control), this.GetType(), "Registration Submitted", "alert('Your registration has been successfully submitted.'); window.location='Registration.aspx'", true);
Or
ScriptManager.RegisterStartupScript((sender as Control), this.GetType(), "Registration Submitted", "alert('Your registration has been successfully submitted.'); window.location='Registration.aspx'", true);