user984599
user984599

Reputation: 11

Accessing Master Page and Nested Master Page Properties from Content Page

How do I access master page properties and a nested master page properties from a content page? I currently use <%@ MasterType in my content page to access properties of the nested master page, but I don't think I can simply specify another mastertype to get to the master page. Or, can I? (IIS6, .Net4, c#).

Thanks, Jon

Upvotes: 1

Views: 2210

Answers (1)

sll
sll

Reputation: 62544

You can access a master page by Page.Master property

Important: (MSDN)

  1. The Master property returns the MasterPage object associated with this page. This property is read-only; however, you can set properties on the MasterPage object it returns.

  2. The Master property is valid only on pages that reference a master page in the MasterPageFile property. If you access the Master property on a page that does not reference a master page, null is returned. The contents of a master page are not available until after the PreInit event has been raised.

Upvotes: 1

Related Questions