ASP.NET Whidbey Overview
page 7 of 14
by Steven Smith
Feedback
Average Rating: 
Views (Total / Last 10 Days): 59354/ 127

Validation Groups

One of the coolest features of ASP.NET is its suite of Validation Controls.  The difference between validating user input in ASP.NET vs. ASP 3.0 with JavaScript is like night and day.  That said, the validation controls do have some severe limitations in ASP.NET 1.0.  One of the largest ones is that validation occurs strictly at the page level, so a page is either valid or it isn't.  This makes it impossible to use these controls to validate separate parts of one page (including panel-based wizard style pages where all the panels are in one page and visibility is controlled by the user's button clicks).

With ASP.NET 2.0, this problem is addressed through the introduction of Validation Groups.  All validation controls and all controls that cause a postback support this new property.  The ValidationGroup property is just a simple text field.  When a postback occurs, only those validators whose ValidationGroup matches the postback control's ValidationGroup (even if it is blank, the default) are fired.  This simple yet elegant solution solves a significant problem with the 1.x implementation of validation.

Validation groups are also supported in code.  A particular group's validity can be checked using

If (Page.Validate("GroupName")) Then

Also, the standard Page.IsValid now evaluates the ValidationGroup associated with the last PostBack.


View Entire Article

User Comments

Title: very good article   
Name: raja raja
Date: 2009-12-04 7:57:23 AM
Comment:
very good and informative website.
Title: nice artical   
Name: abdulla hussein
Date: 2007-04-29 6:28:16 AM
Comment:
I like it , it is very informative . thanks alot man

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-12-04 5:41:50 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search