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

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
very good and informative website.
Title: nice artical   
Name: abdulla hussein
Date: 2007-04-29 6:28:16 AM
I like it , it is very informative . thanks alot man

Product Spotlight
Product Spotlight 

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

©Copyright 1998-2024  |  Page Processed at 2024-04-18 6:42:39 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search