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 1.0 ISBN: 978-0-470-38461-9
This is the forum to discuss the Wrox book Professional ASP.NET MVC 1.0 by Rob Conery, Scott Hanselman, Phil Haack, Scott Guthrie; ISBN: 978-0-470-38461-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 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
  #11 (permalink)  
Old October 8th, 2009, 07:48 AM
Authorized User
 
Join Date: Jun 2009
Posts: 20
Thanks: 0
Thanked 1 Time in 1 Post
Default RE: Dinner Controller Class

Yes AbrarP, you're right. I think it should be:
Code:
ModelState.AddRuleViolations(dinner.GetRuleViolations());
because in previous page, we created an extension method
Code:
public static void AddRuleViolations(this ModelStateDictionary modelState, ...)
.

Hope this helps!
S.
  #12 (permalink)  
Old October 8th, 2009, 09:24 AM
Registered User
 
Join Date: Oct 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default RE: Dinner Controller Class

This is what the book doesn't say (pg 70-71): The code for the controllerhelper class is all wrong...

Incorrect Code:
Code:
public static class ControllerHelpers {    
              public static void AddRuleViolations(this ModelStateDictionary                   
                          modelState,   IEnumerable<RuleViolation> errors) {        
                  foreach (RuleViolation issue in errors) {
                             modelState.AddModelError(issue.PropertyName,              
                                                                  issue.ErrorMessage);
                  }    
              } 
}
Correct Code:
Code:
public static class ModelStateHelpers {

        public static void AddModelErrors(this ModelStateDictionary modelState, IEnumerable<RuleViolation> errors) {

            foreach (RuleViolation issue in errors) {
                modelState.AddModelError(issue.PropertyName, issue.ErrorMessage);
            }
        }
    }
  #13 (permalink)  
Old October 8th, 2009, 10:03 AM
Authorized User
 
Join Date: Jun 2009
Posts: 20
Thanks: 0
Thanked 1 Time in 1 Post
Default RE: Dinner Controller Class

You could either change the method definition or ignore the errata for page 71.

S.
  #14 (permalink)  
Old February 8th, 2010, 08:56 PM
Registered User
 
Join Date: Feb 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Where do you insert the PhoneValidator class? I am finding this follow though very frustrating to say the least :(
  #15 (permalink)  
Old February 9th, 2010, 04:37 AM
Authorized User
 
Join Date: Jun 2009
Posts: 20
Thanks: 0
Thanked 1 Time in 1 Post
Default

@Tharnid: You can add PhoneValidator class to the Helpers folder inside NerdDinner project. That is where all helper classes should be.

If you have more problems, I suggest that you download the sample code for the book. You can get that from here.

Hope it helps.
  #16 (permalink)  
Old May 22nd, 2010, 09:34 AM
Registered User
 
Join Date: May 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Missing comma on page 141

The book authoring/editing process is obviously broken. How hard can it be to copy/paste code from a working program into an authoring tool (i.e., Word, etc.?) This is about the fourth undocumented error I have plowed through while working through this tutorial, and--although there is some educational value in doing your debugging--it is highly irritating.

Anyway, in the introduction of the AJAX call, here is the broken content:

Code:
<%= Ajax.ActionLink( "RSVP for this event",
                             "Register", "RSVP"
                             new { id=Model.DinnerID },
                             new AjaxOptions { UpdateTargetId="rsvpmsg" }) %>
There should, of course, be a comma after the "RSVP" ... so it should look like this:
Code:
<%= Ajax.ActionLink( "RSVP for this event",
                             "Register", "RSVP,"
                             new { id=Model.DinnerID },
                             new AjaxOptions { UpdateTargetId="rsvpmsg" }) %>
I hope this saves at least a few others from debugging drool.
  #17 (permalink)  
Old May 22nd, 2010, 11:28 AM
Registered User
 
Join Date: May 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb TIP, re: Cleanup - Refactoring RSVP and EditAndDeleteLinks Partial Views (Page 147)

Here is a lesson learned which could have been avoided with more explicit instructions, re: creating partial views when doing this refactoring.

For RSVP, the text reads:

Quote:
We can do this by right-clicking on the \Views\Dinners folder and then choosing the Add->View menu command. We’ll have it take a Dinner object as its strongly-typed ViewModel. We can then copy/paste the RSVP content from our Details.aspx view into it.
To be brutally-clear, this could read:

Quote:
We can do this by right-clicking on the \Views\Dinners folder and then choosing the Add->View menu command. We’ll have it take a Dinner object as its strongly-typed ViewModel, and be sure to click on the "Create a partial view (.ascx) option". We can then copy/paste the RSVP content from our Details.aspx view into it.
This is obviously a NEWB observation, but that .ascx nuance is vitally important to actually creating a partial view. Since we created our first partial view MANY pages ago, a more explicit reminder to select the "Create a partial view (.ascx)" option would have been very helpful.

If you (like me) do not click on the "Create a partial view (.ascx)" option in that Create View wizard, here is what you will see when you try to run the updated app and select a dinner event to view:

Quote:
MasterPage cannot be applied to this page because the control collection is read-only. If the page contains code blocks, make sure they are placed inside content controls (i.e. <asp:Content runat=server />)
The key here is the phrase "the control collection is read-only." If you then compare your "partial" pages (which were created as .aspx, not .ascx), you will see that your pages begin with:
Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<NerdDinner.Models.Dinner>" %>
and that the RSVP and EditAndDeleteLinks pages in the NerdDinner 1.0.zip archive of "known-good" source code both begin with:
Code:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NerdDinner.Models.Dinner>" %>
So kewl, let's just copy and paste the code from the "known-good" source code into our "partials," right?

Wrong, because our "partials" were not actually created as partials, this won't work, but the resulting error message does look less onerous:
Quote:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The directive 'control' is unknown.

Source Error:

Line 1: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NerdDinne r.Models.Dinner>" %>
I finally completely removed my RSVP and EditAndDeleteLinks "partials," then looked more closely at the Create View wizard to notice the "Create a partial view (.ascx)" option when I recreated each of them.

I hope others benefit from my hard-learned lesson.

Last edited by StartupGuy; May 22nd, 2010 at 11:48 AM.. Reason: Improve clarity.
  #18 (permalink)  
Old May 22nd, 2010, 03:22 PM
Registered User
 
Join Date: May 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Angry Map Positioning - SUPREMELY FRUSTRATING! (pp 146-153)

Just spent the past 2+ hours trying to get Map positioning away from upper-left (in both FF 3.6.2 and IE8). MANY issues out there about this one.

The most current troubleshooting for this is at the CodePlex site for NerDinner: http://nerddinner.codeplex.com/

Your best bet for Map troubleshooting is to head over to the CodePlex site.

Warning: The NerdDinner project has advanced WAY beyond the scope of this tutorial, so it is very difficult to find solutions specific enough to this (first) generation of the code which do not also introduce new dependencies on later-generation additions to the project.

Good luck to all of us.
 


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 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
More Errors in chapter 7..... rollercoaster BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 5 October 3rd, 2006 03:49 PM
Chapter 6 Try It Out errors Voltron ASP.NET 2.0 Basics 0 August 9th, 2006 01:42 AM
Chapter 4 Errors? DRAYKKO BOOK: Beginning Java 2 3 June 1st, 2004 07:47 AM



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


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