Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Validating Data On Web Forms : Page 4

There are six validation controls included with ASP.NET as well as a summary control. Data validation with the ASP.NET validation controls is always processed on the Web server and can also optionally be processed on the user's computer.




Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js

RangeValidator Control
A developer uses the ASP.NET RangeValidator control to determine if the value entered into a control is included within a specified range of values. The RangeValidator control uses most of the attributes that I've illustrated above in the other validation controls.

The HTML snippet below declares a TextBox control to collect a user's age. The snippet shows how to use the rvAge RangeValidator control to determine if the age entered is within a pre-determined range.

<asp:TextBox ID="txtAge" RunAt="Server" /> <asp:RangeValidator ControlToValidate="txtAge" Display="Static" ErrorMessage="You must be 18 or older to use this page." ID="rvAge" MaximumValue="150" MinimumValue="18" RunAt="Server" Type="Integer" />

The snippet above declares the range for the RangeValidator control using the MaximumValue attribute and the MinimumValue attribute. The Type attribute specifies that you want to compare only an integer data. See the sample validation in action in Figure 4.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date