Best way to globally set every control's ValidationGroup property in an asp.net?
- by Steve Flook
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!