If you use DevExpress and its ASPxButton, you can add client-side confirmation of a button press by setting the button’s ClientSideEvents.Click property to contain Javascript code like this:![]()
MyButton.ClientSideEvents.Click =
@"function(s,e) {
e.processOnServer = confirm('execute this action?');
}";
If the button’s CausesValidation property is set, however, this event handler will be called even if client-side validation raises validation errors. In this case, the confirmation dialog should not be displayed.
This can be solved by calling the ASPxClientEdit.ValidateGroup() client API before displaying the confirmation dialog:
MyButton.ClientSideEvents.Click =
@"function(s,e) {
e.processOnServer =
ASPxClientEdit.ValidateGroup('" + MyButton.ValidationGroup + @"')
&& confirm('execute this action?');
}";
Advertisement
