Web Studyaspnet.blogspot.com Babyneed.blogspot.com

ASP.Net Web Developer Guide

Power By: eXTReMe Tracker Powered by Blogger  
 
 
 
 

 

 
Important Links
 
   
     
 
Sitemap
 
   
   
 
Reference
 
   

Sunday, March 26, 2006

The CompareValidator Control (Chapter 3)

The CompareValidator control compares an input to a specified value or to the value of another control.You can also use it to check if the input is of any particular data type. In our next example, we will add a textbox named txtR. In this textbox, the user will enter the hourly rate. Suppose that we want the data-type of this field to be Double.We will apply a CompareValidator control to test the data-type of the txtR. Note that if the data entered is convertible to the desired data-type, the validation will succeed.The run-time view of the application is shown in Figure 3.54.
Figure 3.54 Using the CompareValidator Control


Please notice that we have set the type property to “Double,” and the operator property to “DataTypeCheck.”
<asp:CompareValidator id="comvR" runat="server" display="static"
controlToValidate="txtR" errorMessage="Rate must be numeric"
type="Double" operator="DataTypeCheck">
</asp:CompareValidator></br>
In the type property of the CompareValidator, we may specify: String, Integer, Double, DateTime, and Currency. In the operator property, we may specify: Equal, NotEqual, GreaterThan, LessThan, GreaterThanEqual, LessThanEqual, and DataTypeCheck.

0 Comments:

Post a Comment

<< Home