Hide user control present in master page

11,013

To get the Masterpage from your aspx page you can use this.Master, and to hide the elements you can set their Visible property to false.

http://msdn.microsoft.com/en-us/library/system.web.ui.page.master.aspx
http://msdn.microsoft.com/en-us/library/486wc64h.aspx
http://msdn.microsoft.com/en-us/library/system.web.ui.control.visible.aspx

((UserControl)this.Master.FindControl("ucTopUser")).Visible = false;
((Button)this.Master.FindControl("btnSub")).Visible = false;
Share:
11,013
ANP
Author by

ANP

Updated on June 04, 2022

Comments

  • ANP
    ANP almost 2 years

    I have an user control in master page with id 'ucTopUser' and a button 'btnSub'.I need to hide the both control from my current aspx page.How can I do this?