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?
The MasterType directive assigns a class name to the Master property of a page, to make it strongly typed.
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.
You can set different master pages at each pages PreInit. So the master page is in general not well defined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With