本文介绍了如何在内容页面中找到母版页的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的母版页上有一个面板推荐。但是我不希望通过在内容页面中找到面板控件来显示在我的内容页面上,并且应该是可见的。
on my master page there is one panel testimonial.but i dont want to display on my content page by finding control of the panel in content page and should be visible false.
//this was the code on content page......
Panel testimonial = (Panel)this.Master.FindControl("testimonial");
testimonial.Visible = false;
//但是此代码不起作用
//but this code is not working
推荐答案
Panel pl = (Panel)Master.FindControl("Panel1");
pl.Visible = false;
public bool TestPanelVisible
{
set
{
pnlTest.Visible = value;
}
get
{
return pnlTest.Visible;
}
}
在内容页面中,您可以将此属性设置为true / false将面板显示/隐藏为:
And in content page you can set this property to true/false when you want to show/hide the panel as :
this.Master.TestPanelVisible = false;
在内容页面中,您必须使用注册Master以下标签:
In the content page you have to register Master using following tag:
<%@ MasterType VirtualPath="~/MasterPage.master" %>
只有这样你才能访问母版页的属性。
希望这有助于: )
问候
Gayatri
Only then you will be able to access master page''s property.
Hope this Helps :)
Regards
Gayatri
这篇关于如何在内容页面中找到母版页的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!