Recently, I received a question referring to our blog Part 2 of 3: Creating shared user controls and master pages with sub-projects , asking how to reference master page’s properties from a sub project.
I searched the answer and find the following MSDN link very helpful: http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx . We need to add the following line in a content page in order to access master page’s property from the content page:
<%@ MasterType virtualPath="~/Site1.master"%>
Then in the same project’s content page’s code behind, we can use “this.Master” which is typed correctly to Site1 class (Site1.master’ class).
Then for any sub projects, all we need to do is to add project reference to the root project, add the MasterType line in the content page, and referring to the root project’s site1.master page as:
Master as RootProject.Site1
Hope this helps any one who have the similar questions.
Web Platform and Tools Team