One Control, Multiple Validators

As previously mentioned, you most likely will need to wire up more than one valiator to one control; for example, the registration page that requires the user to enter a password twice. You most likely would want to make sure they have the fields filled out and the same password is in both TextBox controls. There are a couple benefits to using multiple validators. One benefit is that you can ensure proper data is entered by the user, and the other is that you can give the user different error messages. For instance, if you are using a RequiredFieldValidator and a CompareValidator you can set the RequiredFieldValidators error message to read “Required Field” and the the CompareValidator's to read, “Passwords must ...

Get Programming Data-Driven Web Applications with ASP.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.