Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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 June 22nd, 2012, 05:19 AM
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default consistent pages

Why do I need to create a BasePage that inherits from the Page Class so that I add some code there, can't I just add the code I want to the master.vb??
 
Old June 22nd, 2012, 05:29 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

For some functionality, yes, you could write code in the Master Page. However, since the Master is not a page, not all Page events are available to respond to. In additon, you may have multiple master pages which could mean duplicating code. And finally not all of your pages may be based on a Master Page. By having a central BasePage, these pages could still benefit by the behavior in the BasePage.

Cheers,

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!
 
Old January 29th, 2013, 12:56 PM
bpl bpl is offline
Authorized User
 
Join Date: May 2009
Posts: 21
Thanks: 0
Thanked 1 Time in 1 Post
Default

BasePage is just a class which includes some code. It does not have any other information (for example about Master Page). When we create a new page inherits from BasePage, checkbox "Select Master Page" is disabled. How program knows, that we want to create a new page based on a Master Page? What if we want to use BasePage and the same time want to create page not based on a Master Page? In addition, we may have multiple master pages and want to create a new page based on one of them. How this information can be included in BasePage?
 
Old January 29th, 2013, 01:27 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

>> When we create a new page inherits from BasePage, checkbox "Select Master Page" is disabled. How program knows, that we want to create a new page based on a Master Page?

I think you're mixing uo a few things. The Add New Item dialog is just a quick way to add files to the site. You can still change the Master Page of a page you added in the page directive, or change the BasePage in the code behind. The reason that the checkbox is disabled is because the template you created is one for a Web Form with a Master Page and with a BasePage.

You can create your own templates that either have a Master Page, or a BasePage, or both, or none of them. To see the effect, just create a few different pages and export them as templates.

Hope this helps,

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add Meta Tags to Master Pages/Content Pages Pdesignz BOOK: Beginning ASP.NET 4 : in C# and VB 9 May 31st, 2012 07:08 AM
General question - Master Pages, Base pages, templates and OOP. flapjack BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 May 1st, 2010 09:33 AM
Master Pages, Content Pages and CSS carliviris Visual Studio 2005 0 January 8th, 2008 05:56 PM
Consistent compilation error Chapters 11/12 mnielsen BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 March 31st, 2007 04:35 PM
Web pages constructing: I-mode(mobile) pages karib Dreamweaver (all versions) 3 June 6th, 2004 09:48 AM





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