View Single Post
  #2 (permalink)  
Old May 1st, 2010, 04:15 AM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Sorry to be so pedantic about this but I am really puzzled.
You're not pedantic, so don't worry ;-)

The template file is just that: a template. It's only purpose is to give you a few code files with ready-made code when you create a new page. It's in no way used or around anymore at run-time. Think of it as a Microsoft Word Template: it's just a starting point for new files. So, all it does is give you a new ASPX page where the code behind class inherits BasePage which takes me to your next question.

No, .NET does not support multiple inheritance (although you can implement multiple interfaces). So, a page called MyPage.aspx could have a code behind class called MyPage. This class in turn inherits BasePage which in turn inherits System.Web.UI.Page (which in turn inherits from another class). The full hierarchy is like this:

Master Pages don't participate in the class hierarchy of a Page. Instead, they form their own hierarchy:

If you had the need, you could create your own BaseMasterPage class and let your custom master page inherit from that page. Since you typically only have a few master pages, I usually don't do this though.

At run-time, the Master Page and Content Page are merged to form one complete page. So, code wise they are not related (they don't inherit from each other), but feature-wise they are related of course as together the form the final presentation of the page.

Does this help?

Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
flapjack (May 1st, 2010)