Comparing Data
This one compares data in one field to another field or to a
constant (or a Data Type). It has several options which I will cover now.
- Instead of ControltoCompare you can use ValuetoCompare if
you want to use a constant value.
- Operators can be one of the following:
- DataTypeCheck
- Equal
- GreaterThan
- GreaterThanEqual
- LessThan
- LessThanEqual
- NotEqual
- The Type property can be one of the following:
- Currency
- Date
- Double
- String
- Integer
Here is the example:
First Name:<asp:textbox
id="FName2" runat="server" />Last Name: <asp:TextBox id="LName2" runat="server"
/><p> <asp:CompareValidator runat="Server"
ControltoValidate="FName2" ControltoCompare="LName2" Type="String"
Operator="NotEqual" ErrorMessage="Your First Name can't be your last name
as well!" /> |
This makes sure that your first name isn't your last name
(don't complain if your first name is also your last name, this is just an
example!).