Perform secondary validation on the form

I am using asp.net webforms. FROM#

I want to validate a form. In codebehind im just execute if (Page.isValid).

Once the form fields are correct, I want to perform another validation. The reason I want this split is because it really costs money to do this check, so I only want to do it after all the fields are valid.

Can I programmatically add a validation error to the validation summary? after checking Page.isValid?

Not sure how to solve this.

Any suggestions are greatly appreciated.

+2


a source to share


2 answers


You can put an attribute CustomValidator

without an attribute on the page ControlToValidate

and set its property IsValid

manually after all other checks have completed. This should show it in the summary.



0


a source


If you're interested in a little more control over validation, you should look at FluentValidation . It is a very powerful and intuitive alternative to standard web form validation, and you can strip attributes of your DTO classes. It also works great in tandem with jQuery validation.



0


a source







All Articles