Wednesday 10 April 2013

Validation Controls

         Validation is the process of verifying whether or not the data given by the user is valid. To perform validations on the page. ASP.net provides a set of controls that are collectively called as validation controls. All the validations controls are available within validation tab in the toolbox. 
         In ASP.net 4.5 and visual studio.net 2012 validation controls perform validations using JQuery. Hence you must add JQuery plugin to your website by downloading it from the website www.jquery.com, which is in form of ,jsfile & then writing the following code within application start event within global.asax file. To add global.asax file to the website right click on the website in solution Explorer & choose add new item & within the add new item dialogbox select "Global Application Class" & then click on add button.

Common properties of validation controls

                     The following is the list of properties common to all validation controls.    
  • ControlToValidate: Used to specify id of the control you want to validate using the validation control.
  • EnableClientScript: This is a Boolean property and is used to specify whether or not clientside validation will be performed by the validation control.
  • Text: Used to specify the error message to display within the validation related to tha validation control fails.
  • Error message: Used to specify the error message to display within the validation summery control.
  • ValidationGroup: Used to specify a group name when you want to divide the validation controls into groups.
Validation controls available in ASP.net are as follows
  • RequiredFieldValidator
  • CompareValidator
  • RegularExpressionValidator
  • RangeValidator