Sunday, 27 August 2017

Understanding Validation Controls

Understanding Validation Controls
Everything in the .NET Framework is a class, and the validation controls are no exception. All validation controls in the .NET Framework are derived from the BaseValidator class. This class serves as the base abstract class for the validation controls and provides the core implementation for all validation controls that derive from this class. Validation controls always perform validation checking on the server. Validation controls also have a complete client-side implementation that allows browsers that support DHTML to perform validation on the client. Client-side validation enhances the validation scheme by checking user input as the user enters data. This allows errors to be detected on the client before the form is submitted, preventing the round trip necessary for server-side validation. In addition, more than one validator may be used on a page to validate different aspects. The Validation controls are six types:-
1.       RequiredFieldValidator control
2.      RangeValidator control
3.      RegularExpressionvalidator control
4.      CompareValidator control
5.      CustomValidator control
6.      ValidationSummary control

Using the RequiredFieldValidator Control
Use the RequiredFieldValidator control when a value is required for an input element on the Web page. This control checks whether the value of the associated input control is different from its initial value. You can easily convert the previous sample ASP code into .NET with the RequiredFieldValidator control.

Using the RangeValidator Control
Use the RangeValidator control to determine whether a value falls within the specified range. It checks whether the value of the associated input control is within some minimum and maximum, which can be a constant value or the value of another control.

Using the RegularExpressionValidator Control
Use the RegularExpressionValidator control to check a value against a regular expression. It checks whether the value of the associated input control matches the pattern of a regular expression.

Using the CompareValidator Control
Use the CompareValidator control to make sure that a value matches a specified value. This control compares the value of input control to another input control or a constant value using a variety of operators and types. You can also use this control to make sure that your input value is of a specific type: integer, string, and so on.

Using the CustomValidator Control
Use the CustomValidator control to perform user-defined custom validation. This control allows custom code to perform validation on the client and/or server.

Using the ValidationSummary Control
Use the Validation Summary control to capture all the validation errors from the other controls and display them on the page as a list, a billeted the list, or in single paragraph format. The errors can be displayed inline and/or in a pop-up message box.

https://www.youtube.com/channel/UCKLRUr6U5OFeu7FLOpQ-FSw/videos

0 comments

Post a Comment