Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 November 5th, 2011, 02:13 AM
Registered User
Points: 17, Level: 1
Points: 17, Level: 1 Points: 17, Level: 1 Points: 17, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #2 (permalink)  
Old November 5th, 2011, 04:56 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
jayinatlanta (November 5th, 2011)
  #3 (permalink)  
Old November 5th, 2011, 09:50 AM
Registered User
Points: 17, Level: 1
Points: 17, Level: 1 Points: 17, Level: 1 Points: 17, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
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.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



All times are GMT -4. The time now is 03:50 AM.


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