Wrox Programmer Forums
|
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 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 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()));
 
Old October 9th, 2009, 03:23 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!
The Following User Says Thank You to Imar For This Useful Post:
convert21 (October 9th, 2009)
 
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!
 
Old October 9th, 2009, 03:39 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!





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





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