The easiest way is to just add this to the button which will stop the server-side event from being called if the user chooses Cancel:
Button1.Attributes.Add("onclick", "if ( confirm('Are you sure?') != true ) return false;")
Another way, if you have to have the results server-side is:
In the aspx file:
<input type="hidden" id="Hidden1" name="Hidden1" runat="server">
That adds this to the CodeBehind:
Protected WithEvents Hidden1 As System.Web.UI.HtmlControls.HtmlInputHidden
Then add to the Page_Load event handler:
Dim scriptString As String = "<script language=JavaScript> " + Environment.NewLine
' Store the confirm's return in the hidden control...
scriptString += "document.getElementById('" + Hidden1.ClientID + "').value = " + Environment.NewLine
scriptString += " confirm('Are you sure?'');" + Environment.NewLine
' Do a new PostBack...
scriptString += GetPostBackEventReference(Hidden1, String.Empty) + ";" + Environment.NewLine
scriptString += "</script>"
If IsPostBack AndAlso Request("__EVENTTARGET") = "Hidden1" Then
If Hidden1.Value = "true" Then
' User answered OK
Else
' User answered Cancel
End If
End If
Hidden1.Value = String.Empty