Wrox Programmer Forums

Need to download code?

View our list of code downloads.

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 Search this Thread Display Modes
  #1 (permalink)  
Old October 9th, 2009, 03:13 AM
Registered User
 
Join Date: Oct 2009
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Default Help??!! Error when working in Ch. 13

Hi, I'm in Ch. 13 also. I am on the exercise where you create a page called NewPhotoAlbum.aspx. I have set-up and double checked my linq dbml diagram.

I believe I have done the exercise correctly, but I get this error:

Compiler Error Message: CS1061: 'PhotoAlbum' does not contain a definition for 'Id' and no extension method 'Id' accepting a first argument of type 'PhotoAlbum' could be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 23: // Label1.Text = long_text;
Line 24: PhotoAlbum myPhotoAlbum = (PhotoAlbum)e.Result;
Line 25: Response.Redirect(string.Format("ManagePhotoAlbum. aspx?PhotoAlbumId={0}", myPhotoAlbum.Id.ToString()));
Line 26: }
Line 27: }


This is when I first load the page. If I comment out line 25, the page loads fine and throws an error when I submit it:

Unable to cast object of type 'PhotoAlbum' to type 'PhotoAlbum'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'PhotoAlbum' to type 'PhotoAlbum'.

Source Error:


Line 22: // string long_text = e.Result.ToString();
Line 23: // Label1.Text = long_text;
Line 24: PhotoAlbum myPhotoAlbum = (PhotoAlbum)e.Result;
Line 25: // Response.Redirect(string.Format("ManagePhotoAlbum. aspx?PhotoAlbumId={0}", myPhotoAlbum.Id.ToString()));
Reply With Quote
  #2 (permalink)  
Old October 9th, 2009, 03:23 AM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

A few things to check:

1. Did you add the PhotoAlbum class to the LINQ to SQL diagram?

2. Does your table have an Id column (and did you add it to that table before you added it to the LINQ to SQL diagram?)

3. Do you have a page or another type called PhotoAlbum? It looks like you have a type conflict where another type is called PhotoAlbum as well so the compiler can't find your PhotoAlbum from the LINQ to SQL layer.

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
The Following User Says Thank You to Imar For This Useful Post:
convert21 (October 9th, 2009)
  #3 (permalink)  
Old October 9th, 2009, 03:30 AM
Registered User
 
Join Date: Oct 2009
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Default dude

I don't know what time it is where you are, but it's 3:30 am, and I'm only awake because of my goals re. your book. And here you have just provided almost INSTANT help! Yes, I had a page named PhotoAlbum. That didn't occur to me, and now I've learned something else.

Now I wonder if I'll finish the chapter or go to sleep...

thanks a lot!
Reply With Quote
  #4 (permalink)  
Old October 9th, 2009, 03:39 AM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

It's 9:38 in the morning so I am still fresh..... ;-)

Have fun with the rest of the chapter....

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
Ch. 13 deleting a photo album? Rachel BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 January 1st, 2009 01:23 PM
Getting Array Error message with Begin PHP4 Ch 13 vaderj PHP Databases 4 April 17th, 2005 04:37 PM
ch 13 enum_options.php not working thurmma BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 3 January 27th, 2004 04:26 AM



All times are GMT -4. The time now is 12:28 PM.


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