C#
protected void Page_Load(object sender, EventArgs e)
{
string myScript = @"";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MakeSure", myScript);
form1.Attributes.Add("onsubmit", "return askBeforeSubmit();");
}
VB.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim myScript As String = ""
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "MakeSure", myScript)
form1.Attributes.Add("onsubmit", "return askBeforeSubmit();")
End Sub
You can also ask for confirmation without writing any code. Just use the OnClientClick event on the button as shown below:
OnClientClick="return confirm('Are you sure?');"/>
No comments:
Post a Comment