Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 30th, 2010, 01:49 PM
Authorized User
 
Join Date: Apr 2010
Posts: 18
Thanks: 7
Thanked 0 Times in 0 Posts
Default General question - Master Pages, Base pages, templates and OOP.

Hi Imar,

I'm doing Chapter 6 and am trying to piece it all together. Do the pages which are based on the user defined template actually inherit from Master Page and Base Page. If so, is this multiple inheritance and Does C# support this. Also, does the page inherit from the Template too? I'm trying to fit this in with what I know about the OO Paradigm which I learnt many years ago at Uni using java. I know pages definitely inherit from BasePage, that much is clear, but I don't see where Master Pages and Templates fit in, unless they are part of some (under the hood) .Net Ftamework mechanism and handled differently. Sorry to be so pedantic about this but I am really puzzled.

Cheers Bill
Reply With Quote
  #2 (permalink)  
Old May 1st, 2010, 05:15 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,960
Thanks: 79
Thanked 1,559 Times in 1,536 Posts
Default

Quote:
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:

Code:
System.Object
  System.Web.UI.Control
    System.Web.UI.TemplateControl
      System.Web.UI.Page
        BasePage
          MyPage
Master Pages don't participate in the class hierarchy of a Page. Instead, they form their own hierarchy:

Code:
System.Object
  System.Web.UI.Control
    System.Web.UI.TemplateControl
      System.Web.UI.UserControl
        System.Web.UI.MasterPage
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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
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)
  #3 (permalink)  
Old May 1st, 2010, 10:33 AM
Authorized User
 
Join Date: Apr 2010
Posts: 18
Thanks: 7
Thanked 0 Times in 0 Posts
Default General question - Master Pages, Base pages, templates and OOP.

Many thanks Imar. Starting to understand it now!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Base Page and Master Pages Will BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 14 January 22nd, 2010 05:04 PM
Master Pages micptpuser ASP.NET 2.0 Basics 6 January 8th, 2009 04:50 AM
Master Pages Jayahar ASP.NET 3.5 Basics 1 September 2nd, 2008 05:20 PM
Master Pages, Content Pages and CSS carliviris Visual Studio 2005 0 January 8th, 2008 05:56 PM
Master pages wunnavabk ASP.NET 2.0 Professional 1 June 25th, 2007 08:09 AM



All times are GMT -4. The time now is 09:07 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.