7.6. Validation controls and page validation

We have discussed the Page class in the previous chapter so shall only mention it briefly here. It is worth knowing that it has a Boolean property called IsValid. This property indicates whether or not the page validation has succeeded. By checking this property, we can find out programmatically if the user input has passed all validation rules defined by the validation controls on this page. Here is how it works.

The Page class maintains a list of all validation controls contained in the page in the Validators collection. This collection is an array of IValidator interfaces that are implemented by each validation control. The IValidator interface defines the Validate method and two properties – namely, ...

Get A Programmer's Guide to .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.