devxlogo

Use CausesValidation to Prevent Unwanted Validation Checks

Use CausesValidation to Prevent Unwanted Validation Checks

Validator controls automatically trigger validation checks for every postback?irrespective of whether you need validation or not. To prevent this, set CausesValidation=”False” for the control for which you do not need validation. The code below will help illustrate:

			WebForm1												

If you simply drop two buttons on the form, clicking either button triggers validation by default. But because you don’t need a validation check when you hit Button2, setting CausesValidation=”False” in the Button2 control will do the trick.

devx-admin

Share the Post: