Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| 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 Search this Thread Display Modes
  #1 (permalink)  
Old March 27th, 2009, 10:49 AM
Authorized User
 
Join Date: Mar 2009
Posts: 64
Thanks: 0
Thanked 1 Time in 1 Post
Default Reference to BasePage

In the "Try It Out - Styling the Menu Control", beginning on page 249, and specifically regarding the creation of the folders and aspx pages on page 251, when I compile the project I get an error for each page. The parent class, i.e., BasePage, which is in folder "Classes" (I am using WAP) is shown in each of the new aspx pages as if it were in the directory in which the page is being created. For example, for the AboutUs.aspx in the /About folder the class declaration in AboutUs.aspx.cs is shown as:

public partial class AboutUs : Site.About.Classes.BasePage

rather then what I corrected it to

public partial class AboutUs : Site.Classes.BasePage

Not hard to fix, but kind of annoying. Since I am selecting "MyBasePage" from the "My Templates" section of the "Add New Item" dialog, doesn't VS2008 know where the page is in the structure? Seems weird.

Thomas
Reply With Quote
  #2 (permalink)  
Old March 27th, 2009, 12:45 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You asked for troubles when you switched to a WAP; now you're getting them... ;-)
Quote:
doesn't VS2008 know where the page is in the structure
It knows it exactly; that's why it adds About in the structure..... ;-)

All kidding aside, look in the .cs file in the template's ZIP file. I am pretty sure you'll see something like this:
Code:
 
public partial class $safeitemname$ : $rootnamespace$.BasePage
Simply remove $rootnamespace$ and replace it with the hardcoded namespace for the BasePage class. Then store the .cs file in the ZIP again and it should work.

Rather than using the namespace in front of the class name you also consider a using statement:

Code:
 
using YourNamespaceForBasePage;
...
public partial class $safeitemname$ : 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!
Reply With Quote
  #3 (permalink)  
Old March 27th, 2009, 01:31 PM
Authorized User
 
Join Date: Mar 2009
Posts: 64
Thanks: 0
Thanked 1 Time in 1 Post
Default

Imar,

Yes, I did volunteer to use WAP. I just know there is a pony in there someplace!

I have found that the following works without having to edit the .zip file or add a using statement.

I created a new page in the root of the project and then dragged it to the appropriate folder. The directory structure for the BasePage is then correct and dragging it is an easy step.

Thomas
Reply With Quote
  #4 (permalink)  
Old March 27th, 2009, 01:45 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

That won't work in the long run. You'll end up with classes called Default for example in the same namespace but in different folders. This won't compile.

Fixing the template (two minute job) should fix this.

BTW: the BasePage has nothing to do with *directory structure*; it's prefixed with a namespace. VWD just happens to use the directory structure as the default namespace. May seem insignificant, but thought it was worth mentioning it.

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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
BasePage & MasterPage Rachel BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 December 25th, 2008 11:23 AM
BasePage Code for VB (Chapter 6) justinjones06 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 September 15th, 2008 01:50 AM
BasePage and Namespace Issue Eric S. Smith BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 May 28th, 2008 08:43 AM
BasePage>>TypeInitialization exception nabeelalkaff BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 November 13th, 2007 11:30 AM
reference. scandalous ASP.NET 2.0 Basics 1 April 9th, 2007 07:29 PM



All times are GMT -4. The time now is 04:32 AM.


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