如何隐藏通过一个母版页上的某些页面,而不是其他内容? [英] How to hide content on certain pages and not others via a Master Page?
问题描述
阅读本线程,但并没有真正回答我的问题,并有相当多的建议,所以不知道他们是否在正确的轨道上:<一href=\"http://stackoverflow.com/questions/5893239/master-page-content-filtering-with-respect-to-asp-page\">Master页面内容就过滤,ASP页面
Read this thread but didn't really answer my question and there were quite a few suggestions so not sure if they are on the right track: Master Page content filtering with respect to asp page
我已经是1母版页和它是一个全球性的页脚所有页面使用的网站。我想消除只有1页(即登录页)上的页脚,但保留其他所有的母版页的内容不变。
What I have is a site with 1 Master Page and in it is a global footer that all pages use. I want to eliminate the footer on only 1 page (i.e. the login page) but keep all the other master page content intact.
我知道我可以只为这个登录页面创建一个单独的母版页,但它似乎矫枉过正。有没有把一些逻辑的方式,如果这只是这个特定的页面,它会隐藏页脚,然后显示所有其他网页上?
I know I could create a separate Master Page just for this login page but it seems overkill. Is there a way to put in some logic that if it's only this specific page that it would hide the footer and then show on every other page?
感谢您的任何提示/建议。
Thanks for any tips/suggestions.
编辑:有已经在后面的code页面加载子。所有我不得不添加了 - MasterPage_Footer.Visible =假
IF语句的时候用户没有登录,并将其设置为真
当他们在被记录下来。工程就像一个魅力。感谢所有的建议。
There was already a Page Load sub in the code behind. All I had to add was - MasterPage_Footer.Visible = False
on the If statement when users were not logged in and set it to True
when they were logged in. Works like a charm. Thanks for all the suggestions.
推荐答案
在暴露母版属性,以允许在需要的内容页面覆盖默认行为。
Expose a property on the MasterPage to allow content pages to override default behavior if needed.
在母版:
private bool showFooter = true;
public bool ShowFooter { get {return showFooter;} set {showFooter = value;} }
protected void Page_Load(object sender, EventArgs e)
{
footerControl.Visible = showFooter;
}
请需要访问属性已在ASPX以下行确认内容页:
Make sure content pages that need to access the property have the following line in the aspx:
<%@ MasterType TypeName="XXX" %>
,并在内容页code-背后:
and in the content pages code-behind:
protected void Page_Load(object sender, EventArgs e)
{
Master.ShowFooter = false;
}
这篇关于如何隐藏通过一个母版页上的某些页面,而不是其他内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!