I've got a submit button using Microsoft's ConfirmButton extender to ask "Are you sure?". However it fires regardless of whether or not the page passes client-side validation.
<asp:TextBox ID="TextBox1" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidatorTextBox1"
runat="server"
ControlToValidate="TextBox1"
ErrorMessage="First name is required"
Display="Dynamic" />
...
<asp:Button ID="Button1"
runat="server"
Text="Submit"
CausesValidation="True" />
<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtenderButton1"
runat="server"
TargetControlID="Button1"
ConfirmText="Are you sure?" />
...
<asp:ValidationSummary id="ValidationSummary1"
runat="server"
ShowMessageBox="True" />
So, if a user leaves a required field blank and clicks the "Submit" button. She'll see two message boxes:
One for validation...
ValidationSummary ShowMessageBox http://img120.imageshack.us/img120/8305/validationzn6.gif
Then one for confirmation ...
ConfirmButtonExtender http://img228.imageshack.us/img228/678/confirmationam3.gif
(Note: OK and Cancel both just cancel.)
It doesn't make sense for the confirmation to show up if validation fails. It should be one or the other. How can I do this?
Update:
If I try to use ConfirmOnFormSubmit, then I get this warning:
Validation (ASP.Net): Attribute 'ConfirmOnFormSubmit' is not a valid attribute of element 'ConfirmButtonExtender'.