0
votes

In an ASP.NET WebForm, can I associate a validator to a DropDownList and have the client validation triggered only when a button is pressed, but not when I change the selection in the DropDownList? As far as I can see, when ControlToValidate is set, any selection change in the list triggers the validation.

I tried setting different ValidationGroup values for the DropDownList and the validator, I also set CausesValidation='false' for the DropDownList, with no success. In both cases, the validation is still triggered by the list.

1

1 Answers

0
votes

In case no better idea is found, here is a possible answer to my own question: store a boolean value in a hidden field, to indicate if the validation is bypassed (successful) or if it is performed for real. That value would be used in the client validation function of a CustomValidator. I would bypass the validation by default, and I would force the validation when I click the button.