You can use something like the following:
/// <summary>
/// Add a javascript confirm to a <see cref="WebControl"/>.
/// </summary>
/// <param name="control">Would normally expect this to be a <see cref="Button"/>.</param>
/// <param name="Message">The message to display.</param>
public static void ConfirmButton(WebControl Control, string Message)
{
if (Control != null)
{
Control.Attributes.Add("onclick", "javascript:if(confirm('" + Message + "') == false) return false;");
}
}
Call this in the
OnLoad
event of the page passing the name of the control (usually a button) and a message to display. If the user chooses 'Cancel' nothing will happen. If they choose 'Ok' the process will continue.
You should be able to adapt this to your specific needs: if you're not sure how you'll need to do some research to figure it out.