Tuesday, September 6, 2011

access master page element in content page

I have a  <div> in Master page as below:

<div id="menu">
<a href="Records.aspx">Records</a>
</div>

I want to hide this div in Login.aspx, this can can be achieved using below code from
Login code behind page.


//Hide navigation div from Login page
       
 HtmlContainerControl navDiv = (HtmlContainerControl)this.Master.FindControl("menu");
 navDiv.Visible = false;



To access this <Div> from MasterPage, it should be set to <div id="menu" runat="server">.

No comments:

Post a Comment