I have a nested master page that has its own master page. The parent master page has a property defined in its code behind.
我有一个嵌套的母版页,它有自己的母版页。父母版页面在其代码后面定义了一个属性。
Public ReadOnly Property SelectedPage() As String
Get
Return _selectedPage
End Get
End Property
How can I reference the parent master page's property from within either the child master page's code behind Page_Load or aspx template page?
如何在Page_Load或aspx模板页面后面的子母版页面代码中引用父母版主页面的属性?
4 个解决方案
#1
6
VB.Net:
DirectCast(Master, MyMastPageType).SelectedPage
C#:
((MyMastPageType)Master).SelectedPage
http://msdn.microsoft.com/en-us/library/system.web.ui.masterpage.master.aspx
#2
1
protected void Page_Load(object sender, EventArgs e) { MyDemoMaster m = Master as MyDemoMaster; m.MyProperty = "My button text"; }
See:
- How to access controls inside a nested master page?
- The right way of accessing Master page properties from a child page
如何访问嵌套母版页内的控件?
从子页面访问母版页属性的正确方法
#3
0
Like this:
DirectCast(MyMastPageType, Master).SelectedPage
#4
0
Here is how I use
这是我的使用方法
MasterPage tmp = this.Master;
while (tmp.Master != null)
{
tmp = tmp.Master;
}
#1
6
VB.Net:
DirectCast(Master, MyMastPageType).SelectedPage
C#:
((MyMastPageType)Master).SelectedPage
http://msdn.microsoft.com/en-us/library/system.web.ui.masterpage.master.aspx
#2
1
protected void Page_Load(object sender, EventArgs e) { MyDemoMaster m = Master as MyDemoMaster; m.MyProperty = "My button text"; }
See:
- How to access controls inside a nested master page?
- The right way of accessing Master page properties from a child page
如何访问嵌套母版页内的控件?
从子页面访问母版页属性的正确方法
#3
0
Like this:
DirectCast(MyMastPageType, Master).SelectedPage
#4
0
Here is how I use
这是我的使用方法
MasterPage tmp = this.Master;
while (tmp.Master != null)
{
tmp = tmp.Master;
}