2009 15 Dec

ASP.NET provides developers with many tools for speeding up the development process. Developers often spend a lot of time writing code which checks the data entered by the user in a web form. ASP.NET validation server controls cut down development time by removing the need to write complex validation code to handle client-side and server-side validation of information entered into a form by a user. The controls do more than just validation; they also perform browser detection to check whether JavaScript is enabled on the client’s browser. If JavaScript is enabled, the control sends the necessary JavaScript code to the client; if JavaScript is not enabled, server-side validation takes place.

ASP.NET offers developers six validation controls available in ASP.NET: the RequiredFieldValidator, the CompareValidator, the RangeValidator, The RegularExpressionValidator, The CustomValidator and the ValidationSummary.

The RequiredFieldValidator is the simplest of the bunch. It simply prevents the user from submitting the form without first entering or choosing a value in a required form field. It is often used in conjunction with other validators since, naturally, multiple validators may be applied to the same field.

The CompareValidator performs comparison on the contents of a given form field and another element. The type of comparison can be varied to reflect the type of data the field contains. Thus, for example, if the data is numeric, operators such as equal to, greater than and less than can be used. The comparision will often involve two fields. For example, if your form requests the user’s email address twice to ensure that it has been entered correctly, the CompareValidator can be used to check that the two email address fields contain the same entry.


The RangeValidator verifies that the value entered by the user falls within a certain range. It can be used to perform checks within text ranges, number ranges and date ranges.

The RegularExpressionValidator allows you to define a regular expression against which the value entered in a field can be validated. Regular expressions are a widely-used standard for checking that a given string conforms to a certain pattern. They are notoriously arcane but Visual Studio and Visual Web Developer Express make the process easy by providing a Regular Expression Editor which contains regular expressions for matching common types of data such as email address, web URLs as well as postcodes and telephone numbers for several different countries.

The CustomValidator control offers maximum flexibility in performing validation checks, allowing developers to write custom validation code. The code may be client-side or server side.

The final validation server control, the ValidationSummary control is not itself used for validation. Instead, it works in conjunction with the other controls to provide a mechanism for consolidating error messages generated by other validation controls. It is particularly useful for large forms.

Looking to master ASP.NET website development? We offer ASP.NET training in London and all over the UK.

Possibly related posts: (automatically generated)

Published under Computerssend this post

No User Responded in " Using The Different Types Of Validation Server Controls In Microsoft ASP.NET "

You must be logged in to comment.


create & buy custom products at Zazzle