In this article I will explain about CompareValidator control in ASP.NET. This type of control in ASP.NET help in validation processes, allowing to evaluate values between two input types
Getting Started
What is CompareValidator Control?
CompareValidator Control allows to evaluate the value of an input control against a constant value or the value of another input control to determine whether the two values match the relationship specified.
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtEmail1" ControlToValidate="txtEmail2" ErrorMessage="Emails are different!" Operator="NotEqual"> </asp:CompareValidator>
Example
In this example we will compare two entered emails are equal, Add two labels, two text boxes and a button:
Then, after creating the form, add the CompareValidator control.
This control will compare the value of its ControlToValidate with ControlToCompare. It uses the comparison operators to do the same.
Follow these properties:
The result would be something like this:
This concludes CompareValidator Control in ASP.NET
Looking for quality Windows Hosting? Look no further than Arvixe Web Hosting!
Happy Hosting
Rodolfo Hernandez