Reputation: 433
My alert does not pop up. When I debug this with a breakpoint, this line is executed
Response.Write("<script>alert('" + " We don't seem to have this user registered. Please try again " + "') ; location.href='Login.aspx'</script>");
Upvotes: 0
Views: 2406
Reputation: 2080
You may try this also..
System.Web.UI.ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Your Message.');", true);
Upvotes: 0
Reputation: 10122
see below code sample to get the alert :
Code Behind :
protected void Page_Load(object sender, EventArgs e)
{
System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "abc", "abc();", true);
}
JavaScript :
function abc(message) {
alert(message + ", I am an alert box!");
}
Have a look at My Answer for more information
Upvotes: 0
Reputation: 433
The don't needs to be escaped.
This can be done as follows:
Response.Write("<script>alert('" + " We don\\'t seem to have this user registered. Please try again " + "') ; location.href='Login.aspx'</script>");
It should pop up now.
Upvotes: 3