Logo         Community
The Company
Your Account
Contact Us
Input Validation With ASP.NET (part 1)
Protect your Web application from bad data with ASP.NET's Validator objects.

| Making Friends |

It is a common practice to use client-side scripting languages like JavaScript or VBScript for client side input validation. However, this type of client-side validation is not foolproof - remember, you're not in control of the client, so if a user turns off JavaScript in his or her browser, all your efforts to ensure that the user does not enter irrelevant data will become...well, irrelevant. That's why most experienced developers use both client-side and server-side validation. Server-side validation involves checking the values submitted to the server through a server-side script, and taking appropriate action when the input is incorrect.

That's where the ASP.NET Validator controls come in. In a Web-based application, each Validator control (there are five of them in all, and I've covered them all in this tutorial) is linked to a form control. When a user submits a form, the .NET framework ensures that the data entered by the user is filtered through the Validators, and checked for accuracy. If any of the values flunk the validation tests, an exception is generated; this can then be caught and resolved by the application's exception-handling mechanisms.

With ASP.NET's Validators, it's also possible to perform selective validation, wherein one validation test is dependent on the results of another. For example, if the user states that (s)he's living in the US, you might also require him or her to enter a US state code. However, if the user indicates that (s)he's living outside the US, it doesn't make sense to ask for a state code.

So which kinds of validations are possible using these ASP.NET Validator controls? Here's a quick list:

RequiredFieldValidator -  forces entry of a value for the associated control

CompareValidator - used with a comparison operator to compare the value provided against a constant value or another control

RangeValidator - checks whether the value entered is within a specified range

RegularExpressionValidator - uses regular expressions to validate user input

CustomValidator - allows you to create customized validation routines

How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!

previous page more like this  print this article  next page
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
In cut!...
American Chai
The Core
Find out how you can use this article on your own Web site!

Copyright © 1998-2018 Melonfire. All rights reserved
Terms and Conditions | Feedback