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: Professional ASP.NET MVC 2
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET MVC 2
This is the forum to discuss the Wrox book Professional ASP.NET MVC 2 by Jon Galloway, Scott Hanselman, Phil Haack, Scott Guthrie, Rob Conery; ISBN: Professional ASP.NET MVC 2
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 2 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 18th, 2010, 12:39 AM
Registered User
 
Join Date: Jul 2010
Posts: 2
Thanks: 0
Thanked 2 Times in 1 Post
Default NerdDinner ViewModel Errata

Hey guys,

Noticed some errata in the ViewModel section. I figured I would post it here so other users could see it if they get stuck. Seemed pretty big and had me stuck for a while, so wanted to share.

First, on page 88, it tells you to create a DinnerFormViewModel class, but doesn't say where, the namespace, usings etc. It appeared to be a model, as it uses the Dinner class. So I put it there and made it part of that namespace. I confirmed this is how it is in the NerdDinner 2.0 download zip as well.

However, on page 89 it says to update the inheret tag on your edit page to: Inherits=”System.Web.Mvc.ViewPage<NerdDinner.Con trollers.DinnerFormViewModel>

So... I think that's wrong, should be Models, not controllers.

That's a smaller one, the big one that stuck me was Code snippet 1-52 on the bottom of page 89 start of page 90. It tells you to update your view code for your edit page, but aside from changing the SelectFor tag to consume the new Country SelectList, it doesn't have any of the other number of updates you need to do.

Since you're using the ViewModel now, you need to have everything else use m.Dinner.(property). This also needs to be done to the Create page as well of course, (though you combine them in the next section).

Hope this helps someone.
The Following 2 Users Say Thank You to Darthus For This Useful Post:
athosghost (September 7th, 2010), NightKoder (September 20th, 2010)
  #2 (permalink)  
Old July 18th, 2010, 07:52 AM
Registered User
 
Join Date: Jul 2010
Posts: 2
Thanks: 0
Thanked 3 Times in 1 Post
Default

Quote:
Originally Posted by Darthus View Post
Hey guys,

Noticed some errata in the ViewModel section. I figured I would post it here so other users could see it if they get stuck. Seemed pretty big and had me stuck for a while, so wanted to share.

First, on page 88, it tells you to create a DinnerFormViewModel class, but doesn't say where, the namespace, usings etc. It appeared to be a model, as it uses the Dinner class. So I put it there and made it part of that namespace. I confirmed this is how it is in the NerdDinner 2.0 download zip as well.

However, on page 89 it says to update the inheret tag on your edit page to: Inherits=”System.Web.Mvc.ViewPage<NerdDinner.Con trollers.DinnerFormViewModel>

So... I think that's wrong, should be Models, not controllers.

That's a smaller one, the big one that stuck me was Code snippet 1-52 on the bottom of page 89 start of page 90. It tells you to update your view code for your edit page, but aside from changing the SelectFor tag to consume the new Country SelectList, it doesn't have any of the other number of updates you need to do.

Since you're using the ViewModel now, you need to have everything else use m.Dinner.(property). This also needs to be done to the Create page as well of course, (though you combine them in the next section).

Hope this helps someone.
That is not the only thing you have te change.
To make it work you also have to change the POST Edit method in the controller to let the controller save the changes.

The TryUpdateModel(dinner) will not work anymore because the form values it get are Dinner.Tittle in stead of Tittle.
To fix this you have to add a prefix to the TryUpdateModel (overloaded)

Like this:

[HttpPost]
public ActionResult Edit(int id, FormCollection formValues)
{

Dinner dinner = dinnerRepository.GetDinner(id);
if (TryUpdateModel(dinner, "Dinner"))
{
......
}
The Following 3 Users Say Thank You to hjbaard For This Useful Post:
athosghost (September 7th, 2010), kpthunder (August 13th, 2010), Pete911 (August 26th, 2010)
  #3 (permalink)  
Old July 18th, 2010, 10:38 PM
Registered User
 
Join Date: Jul 2010
Posts: 2
Thanks: 0
Thanked 2 Times in 1 Post
Default

Thanks for the addition.

Just to add to this it looks it continues with the AJAX map starting on page 127. All the Javascript references the controls by names like "Address" and "Latitude", when they should be "Dinner_Address" and "Dinner_Latitude". The online NerdDinner source code reflects this, but the javascript in the book doesn't.

Additionally, the Site.css needs to be updated in order for the map to position and display correctly, but this isn't mentioned at all in the book. I just copied over the .css from the NerdDinner source.
  #4 (permalink)  
Old July 19th, 2010, 01:52 AM
Registered User
 
Join Date: Jul 2010
Posts: 2
Thanks: 0
Thanked 3 Times in 1 Post
Default

Quote:
Originally Posted by Darthus View Post
Thanks for the addition.

Just to add to this it looks it continues with the AJAX map starting on page 127. All the Javascript references the controls by names like "Address" and "Latitude", when they should be "Dinner_Address" and "Dinner_Latitude". The online NerdDinner source code reflects this, but the javascript in the book doesn't.

Additionally, the Site.css needs to be updated in order for the map to position and display correctly, but this isn't mentioned at all in the book. I just copied over the .css from the NerdDinner source.
Looks like they have some editing to do on the book
  #5 (permalink)  
Old July 29th, 2010, 12:33 AM
Registered User
 
Join Date: Jul 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the same problem that you, Darthus. Did Wrox publish a errata about this?
  #6 (permalink)  
Old August 4th, 2010, 01:07 PM
Registered User
 
Join Date: Aug 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default The book is full of errors!

I've been hunkered down with this book for the last two weeks. It's been a good overview, but the examples are full of errors and this has caused me a lot of aggravation! I would expect the authors to get the errata posted as soon as possible in order to save the reputation of the book. I noticed in the acknowledgements that nobody was thanked for checking the book for accuracy . . . I don't think anyone did! With five authors, you'd think one of them could have run all the examples through the latest release of Microsoft software and created an accurate errata. (it's not too late)
  #7 (permalink)  
Old August 26th, 2010, 07:45 PM
Registered User
 
Join Date: Aug 2010
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Default Thanks, this fixed the Edit action for me

Quote:
Originally Posted by hjbaard View Post
That is not the only thing you have te change.
To make it work you also have to change the POST Edit method in the controller to let the controller save the changes.

The TryUpdateModel(dinner) will not work anymore because the form values it get are Dinner.Tittle in stead of Tittle.
To fix this you have to add a prefix to the TryUpdateModel (overloaded)

Like this:

[HttpPost]
public ActionResult Edit(int id, FormCollection formValues)
{

Dinner dinner = dinnerRepository.GetDinner(id);
if (TryUpdateModel(dinner, "Dinner"))
{
......
}
Thanks, this fixed the Edit action for me. The code samples in the book have clearly not been checked against ASP.Net MVC2 RTM.

Pretty disappointing, given how much of a fan I am of the authors. Wrox need to post the errata asap.
  #8 (permalink)  
Old September 3rd, 2010, 04:01 AM
Registered User
 
Join Date: Sep 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Wrong binding in Create action

There is the problem with binding fields in Post Create action. code snippet 1.55.
Some of fields have good binding some of them have null. Do someone have such problem?
  #9 (permalink)  
Old September 6th, 2010, 03:42 AM
Registered User
 
Join Date: Sep 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default fixed

Sorry, guys.
This error was in my code.
  #10 (permalink)  
Old September 14th, 2010, 06:49 PM
Registered User
 
Join Date: Sep 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Great Post

Great Post to resolve some of the initial issues in this book. Would be good if WROX could pull together and make sure the Errata is up to date so that the examples in the book flow(although you do learn a lot from having to figure out these sorts of issues on your own).
 


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
NerdDinner Example Phils_UK BOOK: Professional ASP.NET MVC 2 1 July 6th, 2010 07:49 PM
Chapter 1 - NerdDinner - Errors Steve S BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 17 May 22nd, 2010 03:22 PM
NerdDinner The view 'Index' or its master could not be found rthorington BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 3 May 3rd, 2009 04:30 PM
NerdDinner.Tests Project Missing Stuff dwrogers BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 2 March 22nd, 2009 09:54 AM
Errata ursjenzer BOOK: Professional Assembly Language 0 July 5th, 2005 09:05 AM



All times are GMT -4. The time now is 05:24 AM.


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