Best way to globally set every control's ValidationGroup property in an asp.net?
Posted
by Steve Flook
on Stack Overflow
See other posts from Stack Overflow
or by Steve Flook
Published on 2009-09-15T00:41:02Z
Indexed on
2010/04/13
9:32 UTC
Read the original article
Hit count: 244
I have a User Control with form items that is re-used considerably throughout a large web application, and up until this point the validation summary upon an invalid form submission is being handled by the .aspx that consumes the User Control.
Now I need to set the ValidationGroup property at runtime for each of my form items controls (textboxes, lists, validators, etc). Rather than do it manually by setting each control I'm interested in iterating through all the controls in the User Control, detecting if that control has a ValidationGroup property, and setting it's value that way.
Something like this:
For Each ctrl As System.Web.UI.Control In Me.Controls
' so now what is the proper way to detect if this control has the ValidationGroup property
Next
Code sample in vb.net or c# works for me. Many thanks!
© Stack Overflow or respective owner