Another way to to it:
Expose a public property in your master page that allows content pages to turn visibility on and off. In your master page's code behind you'd do this:
public bool ShowPanel {
get { return myPanel.Visible; }
set { myPanel.Visible = value; }
}
To get a strongly-typed master page property on your content page, you'd add this line to the top of your markup (after the @Page directive):
<%@ MasterType VirtualPath="~/Path/To/Your.master" %> Then in the content page's code behind you can just do this:
Master.ShowPanel = false;
Though this is a bit more involved, it's a nice way of exposing specific properties that you want content pages to have access to, and it is strongly-typed, so problems will be found by the compiler. Additionally, since you presumably already have a reference to the panel in your master page, you save yourself the call to FindControl(), which can cause performance issues when there are a lot of controls on the page.
Original