Reputation: 3143
My Master page
consists of a top bar that contains a few buttons and also a left menu bar by which the user can navigate through the web application. My Login.aspx
page however is a content page but i do not want to show the left menu bar when the content page is login.
Here's a part of my Master page:
<div id="body">
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
<table class="auto-style1">
<tr>
<td class="auto-style2" style="vertical-align: top">
<div id="leftmenu">
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" StaticDisplayLevels="2" Font-Size="Medium">
<LevelSubMenuStyles>
<asp:SubMenuStyle CssClass="level1" />
</LevelSubMenuStyles>
<StaticHoverStyle CssClass="hoverstyle" />
</asp:Menu>
</div>
</td>
<td>
<asp:ContentPlaceHolder runat="server" ID="MainContent" />
<br />
</td>
</tr>
</table>
<section class="content-wrapper main-content clear-fix">
</section>
</div>
I'm looking for a way to check for the name of the opened page in my MainContent
of the Master Page file and if that page is Login.aspx
I would set Menu1
to hidden.
Upvotes: 0
Views: 220
Reputation: 5269
You have to think it in the opposite way: access a Master Page's control from Content Page.
This directive causes the content page's Master property to be strongly typed. Add this in you Content Page:
<%@ MasterType virtualpath="~/YourMasterPage.master" %>
Create the following Property inside your Master Page:
public bool IsMenuVisible
{
get
{
return Menu1.Visible;
}
set
{
Menu1.Visible = value;
}
}
Use it inside your Content Page:
Master.IsMenuVisible = false;
More information:
Reference ASP.NET Master Page Content
Upvotes: 1