Search
Recommended Sites
Related Links






   

Informative Articles

5 Zero-Cost Spam Prevention Tools For All Situations!
Anyone who uses email knows what Spam is! It's annoying and time consuming to wade through volumes of fraud, con and obscene emails to filter out the really important ones. And I am sure you are affected by this menace in some form or other....

Running ColdFusion on your Web Server
Designing a Website in ColdFusion Linux, Solaris, and Windows Servers can run an application called ColdFusion for accessing web pages. A request for web pages is made through an HTTP server in conjunction with a ColdFusion Web...

Showing and Hiding HTML elements using Layers
A long time back I visited a site that had a very fancy, animated navigation bar. Now, as a professional web developer, I'm not in favor of DHTML-supported, fancy navigation bars, but it was very fascinating. What they had done was, whenever you...

When the Clock Strikes Twelve!
I just finished reading another sales copy ending with the Deadline Marketing! And it's the sixth I see today saying "If you order by midnight, blah blah blah...." I'm sure you've seen it. And I'm sure you're getting (if not very) a little bored. ...

Why You Should Stick to Design Conventions
A mistake often made by people who are new to web design is thinking that they shouldn't pay any attention to what has come before: they're going to design a website the way they think one should work. You have to realise, though, that there's...

 
Understanding ASP.NET Validation Controls

Understanding ASP.NET Validation Controls

After you create a web form, you should make sure that mandatory fields of the form elements such as login name and password are not left blank; data inserted is correct and is within the specified range. Validation is the method of scrutinizing that the user has entered the correct values in input fields. In HTML you can perform validation either by checking the values at client-side or after submitting the form at the server-side. But these methods in HTML take lots of time to create and maintain the code. Moreover, if the user has disabled JavaScript then he or she may not receive the message regarding the error.

Therefore, in ASP.NET you can use ASP.NET Validation Controls while creating the form and specify what ASP.NET Validation Controls you want to use and to which server control you want bind this. ASP.NET Validation Controls are derived from a common base class and share a common set of properties and methods. You just have to drag and drop the ASP.NET Validation Control in the web form and write one line of code to describe its functionality.

This reduces the developer time from writing JavaScript for each type of validation. Moreover, through ASP.NET Validation Controls if any invalid data is entered the browser itself detects the error on the client side and displays the error without requesting the server. This is another advantage because it reduces the server load.

The five types of ASP.NET Validation Controls in ASP.NET Framework include:

• RequiredField Validation control: prompts message if any input field is left blank. This validation control can also be used to prompt message to the user if he or she has left any input field with its default value.

• Range Validation control: Prompts message to the user, if the data entered in the input field is not within the range of the values specified by the Maximum and Minimum properties of the validation control.

• Comparison Validation control: Allows the user to compare two values and check for comparisons such as equality, greater-than, less-than etc. In addition you can check whether the data entered in the input field is of the data type as specified by you.

• RegularExpression Validation control: Allows you to validate if the format of a certain input field is correct or not. You can check the validation of the commonly performed formats such as social security numbers, e-mail addresses, telephone numbers, and postal code.

• Custom Validation control: Allows you to define your own condition for validating the data in the input fields. Two validation functions can be performed using Custom Validation control: first on the server-side and second on the client-side. These functions contain logic defined by you to validate the input fields. These functions returns the True value and False value, if the condition you specified is correct or not respectively.

If the control's value does not validate to what you have specified in the validation control tag, the web form displays an error message. Moreover, you can customize the format of the error message by using the control properties such as BackColor, BorderStyle, and BorderWidth. In addition, you can use Cascading Style Sheet (CSS) to format an error message.

To access online version of the above article, please go to http://www.dotnet-guide.com/validation.html



About the Author
Visit http://www.dotnet-guide.com for a
complete introduction to .NET framework.
Learn about ASP.NET, VB.NET, C# and other related technologies.

Sign up for PayPal and start accepting credit card payments instantly.