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

June 22nd, 2012, 05:19 AM
|
Registered User
|
|
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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??
|

June 22nd, 2012, 05:29 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|

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

January 29th, 2013, 01:27 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
>> 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
|
|
 |
|