The CompareValidator Control

The next validator control we'll be talking about is the CompareValidator control. The CompareValidator differs from the previous validator controls because it enables you to compare the value entered by the user with another value. The other value can be that of either another control or a constant value. For instance, if you have a site that has membership that is password controlled during user registration, it is customary to have the user enter their password twice to lessen the chance of entering it incorrectly. You could use the CompareValidator and quickly wire the two Password TextBox controls together to ensure the same value was entered into both.

You can use a couple different attributes to wire up controls ...

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.