Any valid reason to Nest Master Pages in ASP.Net rather than Inherit?

Posted by James P. Wright on Programmers See other posts from Programmers or by James P. Wright
Published on 2012-03-27T18:00:03Z Indexed on 2012/03/27 23:42 UTC
Read the original article Hit count: 377

Filed under:
|

Currently in a debate at work and I cannot fathom why someone would intentionally avoid Inheritance with Master Pages.

For reference here is the project setup:

  • BaseProject
    • MainMasterPage
      • SomeEvent
  • SiteProject
    • SiteMasterPage
      • nested MainMasterPage
  • OtherSiteProject
    • MainMasterPage (from BaseProject)

The debate came up because some code in BaseProject needs to know about "SomeEvent". With the setup above, the code in BaseProject needs to call this.Master.Master. That same code in BaseProject also applies to OtherSiteProject which is just accessed as this.Master.

SiteMasterPage has no code differences, only HTML differences.
If SiteMasterPage Inherits MainMasterPage rather than Nests it, then all code is valid as this.Master.

Can anyone think of a reason why to use a Nested Master Page here instead of an Inherited one?

© Programmers or respective owner

Related posts about inheritance

Related posts about masters