Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
|
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 November 5th, 2011, 02:13 AM
Registered User
 
Join Date: Nov 2011
Posts: 4
Thanks: 2
Thanked 0 Times in 0 Posts
Default Ch 14: Try it Out p. 510 - error 'PlanetWroxModel.Picture' is a 'type'

Here's an error I couldn't find listed elsewhere on the forums.

After completing all the instructions on p. 505-511, (actually even when completing the code on step 12), I get this error:

'PlanetWroxModel.Picture' is a 'type' but is used like a 'variable'

My code looks like Imar's in the book:

Code:
    

using PlanetWroxModel;

...

protected void EntityDataSource1_Inserting(object sender, EntityDataSourceChangingEventArgs e)
    {
        int photoAlbumId = Convert.ToInt32(Request.QueryString.Get("PhotoAlbumId"));
        Picture myPicture = (Picture).e.Entity;
        myPicture.PhotoAlbumId = photoAlbumId;
    }
The line in bold red immediately returns an error, as well as an error at runtime. What did I do wrong?

Jay
 
Old November 5th, 2011, 04:56 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 Jay,

There's one dot too many in this code:

Code:
 
Picture myPicture = (Picture).e.Entity; //Extra . after (Picture)
It should be:

Code:
 
Picture myPicture = (Picture) e.Entity;
By adding the dot, you indeed tell the compiler that (Picture) is a variable with an e property.

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!
The Following User Says Thank You to Imar For This Useful Post:
jayinatlanta (November 5th, 2011)
 
Old November 5th, 2011, 09:50 AM
Registered User
 
Join Date: Nov 2011
Posts: 4
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Ha, thanks Imar! More than one set of eyes is always useful!

Best,

Jay





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch.14 .NETFramework error smileys6971 BOOK: Beginning ASP.NET 4 : in C# and VB 8 February 25th, 2013 02:06 PM
Ch.14 - First try it out jxFive BOOK: Beginning ASP.NET 4 : in C# and VB 3 November 3rd, 2011 03:55 PM
Ch 14 Help digink BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 November 3rd, 2009 03:35 PM
DataRowView Type Not Defined (CH 14) kmwilliams5 ASP.NET 3.5 Basics 5 April 25th, 2009 05:07 AM
CH 14 - Link Error - Unresolved Razzy The Pug BOOK: Ivor Horton's Beginning Visual C++ 2005 2 March 18th, 2008 06:44 PM





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