views:

44

answers:

3

Hi, 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

+1  A: 

In the code-behind, you can just put everything in one parent Panel and set it's Visible property to false;

Steve Danner
good idea too, depends on what he really is trying to achieve with this :)
Stefanvds
A: 

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.

Stefanvds
Yes this is my case
GIbboK
+3  A: 
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);
Dan Dumitru
I think this is your best bet based on your comment response to Stefanvds.
Steve Danner