Home > Articles

  • Print
  • + Share This
This chapter is from the book

That's Not ASP!

With classic ASP, user input validation involved many separate checks, resulting in long, complex code. Listing 7.1 shows an example. The process often required many separate if statements to evaluate several conditions for each control. You had to make sure that users had entered items such as dates, names, and phone numbers in a valid format, and you had to find ways to make those values valid if they were not. This was tedious and error-prone.

With ASP.NET Validation controls, all your classic ASP validation worries fade away. You can validate user input automatically and provide feedback to the user dynamically. No more complex, nested if statements to debug!

Note that all of the functionality you learned about today was possible with classic ASP. However, it was up to the developer to build all of the client-side script and make sure that error messages were displayed properly. If you took a look at the WebUIValidation.js file from Listing 7.4, you'll see that this was not an easy task. There's quite a bit of functionality and code in this file. ASP.NET handles all of this for you, and even adjusts the script depending on the capabilities of the client browser.

Validation controls are one of the greatest improvements of ASP.NET over ASP, and you should take advantage of them thoroughly!

  • + Share This
  • 🔖 Save To Your Account