views:

208

answers:

3

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?

+1  A: 
protected void Page_Load(object sender, EventArgs e)
{
  MyDemoMaster m = Master as MyDemoMaster;
  m.MyProperty = "My button text";
}

See:

Asad Butt
Great links that explain the entire process beautifully +1
Praesagus
Glad, was helpful
Asad Butt
A: 

Like this:

DirectCast(MyMastPageType, Master).SelectedPage
SLaks
+3  A: 

VB.Net:

DirectCast(Master, MyMastPageType).SelectedPage

C#:

((MyMastPageType)Master).SelectedPage

http://msdn.microsoft.com/en-us/library/system.web.ui.masterpage.master.aspx

Russell Giddings
Thanks, that is just what I needed.
WebJunk