Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Saturday, September 02, 2006

Validation Controls in ASP.NET 2.0

One annoying task that most every developer has had to face in the past is form validation. Since forms are an integral part of dynamic, data-driven Web sites, it is essential that a user's query into a form fit the specified guidelines. For example, in a website like eBay where users are entering shipping and billing information, it is vital that the user enter credit card numbers, zip codes, email addresses, and other information in an acceptible format.

Prior to ASP.NET, form validation was a frustrating and tedious process. The page developer was responsible for creating the client-side and server-side logic for each and every validation check. ASP.NET version 1.0 helped end this tedium with a host of validation Web controls, making validation was as simple as adding the appropriate validation control to the web page and setting a few properties.

While validation controls in ASP.NET version 1.x greatly improved the developer's experience with adding page validation, they still lacked some important functionality. For one, the client-side script emitted by the validation controls used the JavaScript object document.all, which is an object that is not in the JavaScript standard and only supported by Microsoft's Internet Explorer browser. This meant that browsers other than Internet Explorer could not enjoy the client-side benefits of the validation controls. Additionally, the validation controls could not be logically grouped, which proved irksome with pages divided up into different sections.

ASP.NET 2.0 doesn't add any new validation controls, but it does fix the validation control shortcomings in version 1.x, along with adding additional features. In this article we'll dissect the validation controls in version 2.0. Read on to learn more!

Post a Comment