HasanG
HasanG

Reputation: 13161

Should I always use MasterType VirtualPath in child master pages

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

Answers (2)

levent
levent

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

Related Questions