Validation in ASP.NET
page 4 of 9
by . .
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 31135/ 159

Comparing Values

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!).


View Entire Article

User Comments

Title: Nice   
Name: Nagesh
Date: 2004-07-13 9:49:31 AM
Comment:
Thanks for such quick review ....
Title: GOOD   
Name: NAGESH
Date: 2004-07-13 8:28:00 AM
Comment:
But where is the code!!!!!!!!!!!!!!!!!

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2019 ASPAlliance.com  |  Page Processed at 2019-04-23 10:34:33 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search