Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is @MasterType directive not implied when setting @Page masterPageFIle?

The docs for @MasterType have this example.

<%@ Page  masterPageFile="~/MasterPage.master"%>
<%@ MasterType  virtualPath="~/MasterPage.master"%> 

Why is @MasterType even needed? Couldn't the compiler automatically take the same actions based solely on @Page masterPageFile? When would you not want to use both?

like image 240
Samuel Neff Avatar asked Jan 28 '10 14:01

Samuel Neff


People also ask

What is master type directive?

The MasterType directive assigns a class name to the Master property of a page, to make it strongly typed.

How do you access a public property defined in a master page from the content page?

To access members of a specific master page from a content page, you can create a strongly typed reference to the master page by creating a @ MasterType directive. The directive allows you to point to a specific master page. When the page creates its Master property, the property is typed to the referenced master page.


1 Answers

You can set different master pages at each pages PreInit. So the master page is in general not well defined.

like image 69
Dirk Brockhaus Avatar answered Sep 20 '22 17:09

Dirk Brockhaus