Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| 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 September 9th, 2010, 07:52 AM
Registered User
 
Join Date: Sep 2010
Posts: 5
Thanks: 0
Thanked 6 Times in 3 Posts
Default Errata

Here are some of the errors I have found, that have you frustrated wondering if it is you or the book that is the problem:

page 30:
"entities.RSVPs.DeleteObject(dinner.RSVPs);" is wrong, should be "entities.RSVPs.DeleteObject(rsvp);"

page 35:
"[StringLength(265, ErrorMessage =" is wrong, should be "[StringLength(256, ErrorMessage ="

page 61:
The descriptions associated with the EventDate and ContactPhone fields in Figure 1-84 are inconsistent with the code. Adding a DisplayName attribute to the properties in your Dinner partial class will allow you to change the labels. This same problem is evident in other figures later in the book.

page 73:
The code for the create.aspx view will not create the look that is in figure 1-94. This is sorted out later when you implement a partial view based on the edit.aspx view, so don't worry about it.

page 89:
It is not clear from the code that the code on your edit view will now be like this:

<%: Html.LabelFor(m => m.Dinner.Title) %>

Instead of this:

<%: Html.LabelFor(m => m.Title) %>

i.e. Where "m." was present before it will be replaced by "m.Dinner." throughout the code in the view.

page 90:
As we are now using a DinnerFormViewModel in the view the TryUpdate in code snippet 1-53 needs to be changed.

"if (TryUpdateModel(dinner))" needs to be changed to "if (TryUpdateModel(dinner,"Dinner"))"

page 107:
You need to fully qualify the model you are inheriting from, i.e. you need to use this:

<NerdDinner.Helpers.PaginatedList<NerdDinner.Model s.Dinner>>

instead of this which is suggested in the book:

<NerdDinner.Helpers.PaginatedList<Dinner>>
The Following 4 Users Say Thank You to frez For This Useful Post:
firedrawndagger (October 12th, 2010), flyinhawaiian (October 7th, 2010), Ole F (September 25th, 2010), Rushino (January 2nd, 2011)
  #2 (permalink)  
Old September 21st, 2010, 02:29 PM
Registered User
 
Join Date: Sep 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Please help me. My problem is :

I created private NerdDinnerEntities object 'entities'. There are two model classes in Entity i.e. Dinner and RSVPs. While implementing Insert/Delete method in DinnerRepository Class i stuck at entities.Dinner. because there is know Addobject() available neither the DeleteObject(). I couldnt even access entities.RSVPs instead intelissence shows entities.RSVPsSet

Help me out.

Thanks...
  #3 (permalink)  
Old September 25th, 2010, 02:29 PM
Registered User
 
Join Date: Sep 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default About PaginatedList class

where to add PaginatedList<T> class in the project.
  #4 (permalink)  
Old September 25th, 2010, 02:36 PM
Registered User
 
Join Date: Sep 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default PaginatedList

<NerdDinner.Helpers.PaginatedList<NerdDinner.Mod el s.Dinner> Will you explain Helpers come from where?
  #5 (permalink)  
Old September 26th, 2010, 06:49 PM
Registered User
 
Join Date: Sep 2010
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default [DisplayName] attribute problems?

Hi, thats a very usefull errata, many thanks. One problem though on the page 61 tip, when I try to change the display names by adding a [DisplayName] attribute to the Dinner Partial class, when I start to type [DisplayName], it does not appear as an option in the intellisense?
I am using the System.ComponentModel.DataAnnotations reference and the [Required] and [StringLength] attributes work OK. Not sure what I am doing wrong?
  #6 (permalink)  
Old September 26th, 2010, 06:59 PM
Registered User
 
Join Date: Sep 2010
Posts: 5
Thanks: 0
Thanked 6 Times in 3 Posts
Default

Quote:
Originally Posted by Mossyman View Post
Hi, thats a very usefull errata, many thanks. One problem though on the page 61 tip, when I try to change the display names by adding a [DisplayName] attribute to the Dinner Partial class, when I start to type [DisplayName], it does not appear as an option in the intellisense?
I am using the System.ComponentModel.DataAnnotations reference and the [Required] and [StringLength] attributes work OK. Not sure what I am doing wrong?
You need to add a using System.ComponentModel to the Dinner partial class, then you can add the attribute, e.g. [DisplayName("Event Date")]
The Following User Says Thank You to frez For This Useful Post:
Mossyman (September 27th, 2010)
  #7 (permalink)  
Old September 26th, 2010, 07:00 PM
Registered User
 
Join Date: Sep 2010
Posts: 5
Thanks: 0
Thanked 6 Times in 3 Posts
Default

Quote:
Originally Posted by dpuranik View Post
<NerdDinner.Helpers.PaginatedList<NerdDinner.Mod el s.Dinner> Will you explain Helpers come from where?
Helpers is a new folder you need to create that will contain the PaginatedList class.
  #8 (permalink)  
Old October 4th, 2010, 10:08 PM
Registered User
 
Join Date: Oct 2010
Posts: 2
Thanks: 5
Thanked 0 Times in 0 Posts
Default Page 89

On the top of page 89 - they say to change the Inherits attribute like so:
Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<NerdDinner.Controllers.DinnerFormViewModel>" %>
but shouldn't it be more like so?
Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<NerdDinner.Models.DinnerFormViewModel>" %>
Because on page 94, DinnerFormViewModel reappears on the screenshot - and it clearly states NerdDinner.Models.DinnerFormViewModel

I swear this book is a mystery novel.
  #9 (permalink)  
Old October 5th, 2010, 04:32 AM
Registered User
 
Join Date: Sep 2010
Posts: 5
Thanks: 0
Thanked 6 Times in 3 Posts
Default

Quote:
Originally Posted by firedrawndagger View Post
I swear this book is a mystery novel.
Lol, well chapter 1 is for sure, in fact I never bothered finishing it all, however, once you have finished that hurdle the rest of the book is very good.
  #10 (permalink)  
Old October 7th, 2010, 10:20 AM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default m.Title versus m.Dinner.Title

Another way to fix issue on page 89 is to use a Custom-Shaped ViewModel Class (which is mentioned in page 91).

Just modify your existing DinnerFormViewModel.cs to expose individual properties of Dinner:

Code:
public string Title
{
    get { return Dinner.Title; }
    set { Dinner.Title = value; }
}
If you expose just the properties needed for the view, you can still use
<%: Html.LabelFor(m => m.Title) %> in the view.

Also, since the view never directly references Dinner, you can make it private.


There are times where it is very useful to be able to shape the view like this (remember "separation of concearns"). Look at m.Title versus m.Dinner.Title. Think about this. What would happen if you swapped out the Dinner model with something new like FineDining model? You could then change the viewmodel and not change anything in the view. If needed you could "translate" property names like this:

Code:
public string Title
{
	get { return FineDining.MyFineTitle; }
	set { FineDining.MyFineTitle= value; }
}
Using this modified ViewModel has apparently fixed issue with page 90. So using "if (TryUpdateModel(dinner))" works now. And doesnt need to be changed to "if (TryUpdateModel(dinner,"Dinner"))"

btw, thanks to all who contributed here. It really helped me out.

Last edited by flyinhawaiian; October 7th, 2010 at 11:01 AM.. Reason: added code tags
 


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
Errata Eddierocks BOOK: JavaScript Programmer's Reference 14 March 31st, 2011 12:54 PM
A new errata Cookie Chen C# 1 November 12th, 2007 05:12 AM
Errata omarosa BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 7 October 6th, 2005 09:21 AM
Errata edsmithed BOOK: Professional Java Development with the Spring Framework 4 August 9th, 2005 04:32 PM
Errata ursjenzer BOOK: Professional Assembly Language 0 July 5th, 2005 09:05 AM



All times are GMT -4. The time now is 01:14 AM.


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