Validation controls in ASP.NET

M.SARULATHA
Assistant Professor
Dept. of CA,JJC.

Validation controls are used,

• Use the concept of an introduction.

• Verification of user input data.

Data format, data type and data range are used for authentication.

Validation has two types

1. Client Side

2. Serve Side

    Client side validation is good but we should rely on language support in the browser and scripts. Client side validation is considered easy for users as they get a quick response. The biggest advantage is that it prevents the page from going back to the server until client verification is done successfully.

    At the developer point the developer is preferred because it will not fail, it does not depend on the browser and writing language.

     You can use ASP.NET Validation, which will verify client, and server authentication. It works on both sides; the first will work on customer verification and there is server verification. Any cost server verification will always work whether customer verification is done or not. You therefore have the security of a verification test.

     The .NET client script used JavaScript. The WebUIValidation.js file is used for customer verification by NET

 Validation controls on ASP.NET

     An important feature of building ASP.NET web pages is the user input to be able to check that the information users enter is valid. ASP.NET provides a set of verification controls that provide an easy-to-use but powerful way to check for errors and, if necessary, deliver messages to the user.

 There are six types of validation controls in ASP.NET

1. RequiredFieldValidation Control

2. CompareValidator Control

3. RangeValidator Control

4. RegularExpressionValidator Control

5. CustomValidator Control

6. Verification Summary

The table below describes the controls and their function,

Validation Control

                                Description

RequiredFieldValidation

                Makes an input control a required field

CompareValidator                

                 Compares the value of one input control to the value                     of another input control or to a fixed value

RangeValidator

                Checks that the user enters a value that falls between                     two values

RegularExpression

Validator

                Ensures that the value of an input control matches a                         specified pattern

CustomValidator

                Allows you to write a method to handle the validation of                 the value entered

ValidationSummary

                Displays a report of all validation errors occurred in a                     Web page

All validation controls are rendered in form as <span> (label are referred as <span> on client by server)

Validation Properties

    Usually, Validation is invoked in response to user actions like clicking submit button or entering data. Suppose, you wish to perform validation on page when user clicks submit button. Server validation will only performed when CauseValidation is set to true.

     When the value of the CausesValidation property is set to true, you can also use the ValidationGroup property to specify the name of the validation group for which the Button control causes validation.

     Page has a Validate() method. If it is true this methods is executed. Validate() executes each validation control.

     To make this happen, simply set the CauseValidation property to true for submit button as shown below:

 <asp:Button ID="Button2" runat="server" Text="Submit" CausesValidation=true />


Comments

Popular posts from this blog

Operating System Structure

Asymptotic Notations

ASP.NET Events Handling