Using the CustomValidator Control

If none of the other validation controls perform the type of validation that you need, you can always use the CustomValidator control. You can associate a custom validation function with the CustomValidator control.

The CustomValidator control has three important properties:

ControlToValidate The ID of the form field being validated.

Text The error message displayed when validation fails.

ClientValidationFunction The name of a client-side function used to perform client-side validation.

The CustomValidator also supports one event:

ServerValidate This event is raised when the CustomValidator performs validation.

You associate your custom validation function with the CustomValidator control by handling ...

Get ASP.NET 4 Unleashed 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.