Validation Summary and Multiple Validation Groups

I was recently working with an application where I had to add an additional validation summary, and trigger the validation manually through the Page.Validate() method. I had to do this because of the way that the form needed validation. So, the approach I took was to create a validation group, for the controls that were defined in a user control, and call Page.Validate() and Page.Validate("Group") in the one button event handler, and Page.Validate() in the other.

What I found was Page.Validate() called everything in the button event handler I didn't want it to. It turns out to call the main validation group, one must call Page.Validate(nothing) or Page.Validate(null). The next problem I ran into was that any errors on that validation group didn't get added to the validation summary control, because the validation summary only works with validators defined in the same validation group. This posed a problem for me, because it was all in one form and I didn't want extra validation summaries; that would have been confusing.

The alternative approach was after calling Page.Validate("Group"), to use GetValidators("Group") to get the validators in the other group, then to duplicate them by adding them to the validation summary using a new validator with no validation group. (To do this, I used an approach similar to http://www.codeproject.com/aspnet/RuntimeValidation.asp). This worked fine then.

Published Wednesday, October 10, 2007 8:06 PM by bmains
Filed under:

Comments

# re: Validation Summary and Multiple Validation Groups

Monday, December 31, 2007 4:38 AM by Syouf

i have the same problem, i have web page consist

of more than 3 user controls and each control have required field validator, when u click in any of submite button all validators works and i cant add validator group for each control, i used frame work 2003

The leading UI suite for ASP.NET - Telerik radControls
Outstanding performance. Full ASP.NET AJAX support. Nearly codeless development.