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 c开发者_如何学JAVAan I do this?
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;
Another possibility is to use jQuery. Just add $("#ucTopUser").hide(); $("#btnSub").hide();
to your $(document).ready() function.
精彩评论