Hiding all panels on a web content form within a master page

Posted by Jack Marchetti on Stack Overflow See other posts from Stack Overflow or by Jack Marchetti
Published on 2010-05-07T16:29:37Z Indexed on 2010/05/07 16:38 UTC
Read the original article Hit count: 213

Filed under:
|
|
|

I'm trying to hide all panels on a page, when a button click occurs.

This is on a web content form, within a master page.

The contentplageholder is named: MainContent

So I have:

foreach (Control c in Page.Form.FindControl("MainContent").Controls) {
    if (c is Panel) {
        c.Visible = false;
    }
}

This never find any panels. The panels are within an Update Panel, and I tried

foreach(Control c in updatePanel.Controls) { }

and this didn't work either. I also tried :

foreach(Control c in Page.Controls) { }

and that didn't work either.

Any idea what I'm missing here?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about panel