Social Icons

Wednesday, 15 May 2013

Asp.Net Validation Controls Tutorial

Asp.Net Validation Server Controls


In my previous article i explained difference between web.config and app.config, WPF architecture overview, 3- tier architecture in .net application. Now i will explain Asp.Net Validation Server Controls.


Validation Server Controls:

Validation Controls used for validating user input data, data format, datatype and range of value.

 Validation Types:

Validation is two types.
 1. Client Side
 2. Server Side.

Client Side Validation: 
 Performs validation without submitting the page to server(postback) with the help of scripting languages. Client Side validation is always preferable as it increases responsiveness of the webpage and users get instant feedback. But this is dependent on browser and Scripting language like javascript.
ServerSide Validation:
Developers prefer ServerSide validation as it is not dependent on browser and Scripting language.
You can use Asp.Net Server Controls which Provide both the Client Side and Server Side Mechanisms.

Asp.Net Validation Server Controls:

Asp.Net provides seperate controls for validating user input in a customized way. These Controls provide both server side and client side validations automatically. Validation Controls detects client browser for client-side validation.If it is enabled it adds javascript code for client-side validation if it is not then bypassed it to perform server-side validation. In the case of client-side validation when user clicks CausesValidation button the same error messages will display without submitting page to server.

Enable/Disabling Client-Side validation:
 we can enable/disable the client-side validation by setting enable/disable to EnableClientScript Property of the Validation Control. If client-side validation is set then page includes scripts to perform client-side validation.(WebUIValidation.js).

Disabling Client-Side validation in Asp.Net Page:

if you want to forcebly disable client-side validation on the page then set page attribute ClientTarget to DownLevel.

If you set ClientTarget attribute to UpLevel then forces controls to perform both validations.

Asp.Net Provides following controls to perform validation.

1. RequiredFieldValidator
2. CompareValidator
3. RangeValidator
4. ReqularExpressionValidator
5. CustomValidator


This Control is simple validator control which checks whether data is entered in input control. Use RequiredFieldValidator to Make an input control as mandatory field.

RequiredField Validator Explanation with Example


 Compares the value of one input control to another input control or a constant value.

 Compare Validator Explanation with Example


Checks the value of input control is in the specified region.

RangeValidator Explanation with Example


Checks the value of the input control matches the specified pattern.


Allows you to write custom method to perform custom validation.


Used for displaying summary of all errors on the webpage.


I hope you got an idea about what are Asp.Net Validation Controls, Enable/Disable Client-Side Validation at Control level and page level. In my next article i will explain each Asp.Net Validation Server Control in detail.
         I would like to have feedback from my blog readers. Your valuable Suggestions,Questions,Comments and other requirements are always welcome.

Related Tutorials

No comments:

Post a Comment

Please Give your Valuable Suggestions,Questions and Comments to improve my blog.