I have an ASP.NET page. I want to throw a pop up upon clicking a certain button on the page. The syntax I used is this:
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Invalid Address!!');", true);
The popup did not appear.
However, when trying the same syntax on a different page in the same project, it worked.
Any ideas?
Try changing the below line from
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Invalid Address!!');", true);
to
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "popup", "alert('Invalid Address!!');", true);
If for whatever reason the above code doesn't work, try the below if it works
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert",
"Javascript:displayAlert('Invalid Address!!');", true);
and your JS function
function displayAlert(msg) {
alert(msg);
return false;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.