Reputation: 13161
I have many master pages inside an asp.net web forms project.
For example, Sub.master is using Main.master as master page and the sub master has following directive:
<%@ MasterType VirtualPath="~/Main.master" %>
An experienced developer tells me to use it even I'm not accessing the Page.Master inside the sub master/page because it makes the page Strongly Typed. What are the pros and cons using this directive if any? Because I cannot decide if I should add it on every web form page too.
Upvotes: 2
Views: 833
Reputation: 3634
At first glance it looks good but I never liked direct access to an object,control or method belonging to the master page.
I think there must be a standard of communication like event bubbling (master to child or child to master).
<%@ MasterType TypeName="BaseMaster" %> seems to be good in establishing this standard.
Upvotes: 0
Reputation: 35524
It provides a way to create a strongly typed reference to the ASP.NET master page when the master page is accessed from the Master property.
See
Upvotes: 1