Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 15th, 2011, 10:51 AM
Registered User
Points: 13, Level: 1
Points: 13, Level: 1 Points: 13, Level: 1 Points: 13, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Nov 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question Base Page / Master Page Confusion

Hi there.

I've been doing Beginning ASP 4, and I've confused myself about base pages and master pages, specifically when to use one, or the other, or both.

I did a little test whereby I've entered the following code:

this.page.title = ("XXXX Title")

where XXXX = BasePage, MasterPage or just Page.

I've found that the page overrides the master page which overides the base page. Presumable because they are applied at different stages of the lifecycle. But it got me to thinking, why use a base page at all? You could stuff all the code common to every page in the master page codebehind, then it's all neat and in one place.

Every content page you do receives all the code from the masterpage, so what's the point of a base page?

I'm not sure I get the whole object oriented thing yet... :-/

Thanks for any insights!

Old December 16th, 2011, 09:01 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi Mark,

You should see the master page as a common place for design, and a base page as a common place for behavior. There's some overlap (such as setting the title) between the two, but in general they serve different purposes. For example, it you added a method to do something on each page to the BasePage, it becomes available to all pages using that BasePage automatically and you could call it directly from those pages.


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!

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the Master page hoses site... Page 92... richv BOOK: Beginning SharePoint 2010 Development 19 December 30th, 2010 10:21 AM
Creating a base page confusion Kerblamalot ASP.NET 3.5 Basics 4 February 3rd, 2010 04:16 AM
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 Page and Content Page with Java script Harjinder ASP.NET 2.0 Professional 1 February 1st, 2008 10:31 AM
Access Master page control from Content page. angshujit ASP.NET 2.0 Basics 3 January 11th, 2007 06:20 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.