Reputation: 73908
I am using asp.net 4.
I need set up for all Panels WebControl for a page their visibility to false like
uxTypesDisplayer.Visible = false;
I need to setup visibility for all this panel without mention the single ID for every single panel.
Do you know guys how to do it? Thanks
Upvotes: 0
Views: 2959
Reputation: 5423
public void HidePanelsRecursively(Control container)
{
if (container is Panel)
container.Visible = false;
foreach (Control ctrl in container.Controls)
HidePanelsRecursively(ctrl);
}
And then just call it like this in your Page's code-behind:
HidePanelsRecursively(this);
Upvotes: 6
Reputation: 5916
why do you need this?
are you trying to show no panel by default, and then by some logic display 1 or more of them?
in this case, add the parameter visible="false"
in your aspx page for each panel.
Upvotes: 0
Reputation: 22148
In the code-behind, you can just put everything in one parent Panel
and set it's Visible
property to false;
Upvotes: 1