In Web Forms project i need to open alert.
I try to do it like this
var script = Page.ClientScript;
if (!script.IsClientScriptBlockRegistered(this.GetType(), "SignOffAlert"))
{
script.RegisterClientScriptBlock(this.GetType(), "text", "SignOffAlert");
}
and add js-function on view
function SignOffAlert() {
alert('The form cannot be submitted!');
}
On Button click alert is absent
Update :
This code works for me
var script = Page.ClientScript;
if (!script.IsClientScriptBlockRegistered(this.GetType(), "signOffAlert"))
{
script.RegisterClientScriptBlock(this.GetType(), "signOffAlert", "alert('The form cannot be submitted!');", true);
}
try this, in the Page_Load write this:
and in then Form