Examining the CompareValidator

The CompareValidator validation control is useful for comparing the value of a user's input to a constant value or to the value of a different user input. For example, on the ValidationControlTestBed.aspx ASP.NET Web page, the last two inputs, which ask users for the total number of children they have and the number of male children, are prime candidates for the CompareValidator.

The input that prompts users for their total number of children, for example, must be a value that is greater than or equal to 0. The input for the number of male children must be both greater than or equal to 0 and less than or equal to the value the user entered into the total number of children textbox.

Let's first provide this validation ...

Get SAMS Teach Yourself ASP.NET in 24 Hours 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.