Page 1 :
Validation Web Server Controls, People concerned with validating user input often use the mantra: Never trust user input., , To help you overcome this problem as much as possible, ASP.NET provide a range of validation controls that help you validate data, before it is used in your application., , This client-side validation works on most modern web browsers with JavaScript enabled, including Internet Explorer, Firefox, Chrome, Opera, and Safari., , At the same time, the validation is also carried out at the server automatically.
Page 2 :
Validation Web Server Controls, Declared on web form and bound to input control, More than one validator can be attached to a control., CauseValidation property of button to be set to true for validation to take place., Controls are, RequiredFieldValidator, CompareValidator, RangeValidator, CustomValidator, RegularExpressionValidator, ValidationSummary
Page 3 :
RequiredFieldValidator, The RequiredFieldValidator control ensures that the required field is not empty. It is generally tied to a text box to force input into the text box., The syntax of the control is as given:
Page 4 :
RangeValidator, The RangeValidator control verifies that the input value falls within a predetermined range., It has three specific properties:
Page 5 :
CompareValidator, The CompareValidator control compares a value in one control with a fixed value or a value in another control., It has the following specific properties:
Page 6 :
The RegularExpressionValidator, The RegularExpressionValidator allows validating the input text by matching against a pattern against a regular expression. The regular expression is set in the ValidationExpression property., The following table summarizes the commonly used syntax constructs for regular expressions:
Page 7 :
The RegularExpressionValidator, Apart from single character match, a class of characters could be specified that can be matched, called the metacharacters.
Page 8 :
Validation Web Server Controls, The Standard Validation Controls:, , The five validation controls (the ones in the Validation category of the Toolbox whose names end in Validator) ultimately all inherit from the same base class, and thus share some common behaviour., , Four of the five validation controls operate in the same way, and contain built-in behaviour that enables you to validate associated controls., , The last control, the CustomValidator, enables you to write custom validation rules not supported out of the box.
Page 9 :
Validation Web Server Controls, The CustomValidator:, The CustomValidator control allows writing application specific custom validation routines for both the client side and the server side validation.
Page 10 :
Validation Web Server Controls, The ValidationSummary Control, The ValidationSummary control does not perform any validation but shows a summary of all errors in the page., The summary displays the values of the ErrorMessage property of all validation controls that failed validation., The following two mutually inclusive properties list out the error message:, ShowSummary: shows the error messages in specified format., ShowMessageBox: shows the error messages in a separate window
Page 11 :
Validation Web Server Controls, Validation Groups:, Complex pages have different groups of information provided in different panels. In such a situation a need for performing validation separately for separate group, might arise. This kind of situation is handled using validation groups., To create a validation group, you should put the input controls and the validation controls into the same logical group by setting their ValidationGroup property.