Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Method to set all controls Enabled property to false
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01319086
Message ID:
01319093
Views:
26
This message has been marked as the solution to the initial question of the thread.
>
>When I set this property, I want to set all its inner controls Enabled property to the passed value.

You can iterate over the Controls collection to do this.

>Also can I have this as a static method in our public static class? If yes, what should I pass to this method?

Sure. You could pass in either a UserControl, or a ControlCollection.
public static void SetEnabled(ControlCollection cc, bool enabled)
{
    foreach (Control control in cc)
    {
        WebControl webControl = control as WebControl;
        if (webControl != null)
            webControl.Enabled = enabled;
    }
}
This isn't recursive, but should point you in the right direction.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform