Thread: C# основной форум/Hide masterpage table

Hide masterpage table
You have to expose the Table from the master page. You can do that by addind a property to your master page. From the Content page you can use the Master class to access your property:


MasterPage:


public Table GetTable

{

    get { return myTable1; }

}


Conentpage:

Master.GetTable.Visible = false;



Put this in your content page:

protected

void Page_PreRender(object sender, EventArgs e)
{
    Panel panel = (Panel)Master.FindControl("panel");
    panel.Visible = false;

}



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