Wrox Programmer Forums
| 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 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
  #1 (permalink)  
Old September 8th, 2010, 07:14 PM
Registered User
 
Join Date: Sep 2010
Posts: 3
Thanks: 3
Thanked 0 Times in 0 Posts
Default PaginatedList

Ok,

So I'm supposed to change the Inheritance from
<IEnumerable<Dinner>>

to

<NerdDinner.Helpers.PaginatedList<Dinner>>

That's fine, but when you do this the page blows up. The main error seems to be that it cannot find the Dinners namespace (which is really really weird).

The entire class doesn't make much sense to me either. If we are now passing the PaginatedList to the view as the model, then the class doesn't have any type of public property for the dinners iteration.
  #2 (permalink)  
Old September 9th, 2010, 07:45 AM
Registered User
 
Join Date: Sep 2010
Posts: 5
Thanks: 0
Thanked 6 Times in 3 Posts
Default

This is because they don't mention you need to fully qualify your model, i.e.

<NerdDinner.Helpers.PaginatedList<NerdDinner.Model s.Dinner>>
The Following User Says Thank You to frez For This Useful Post:
athosghost (September 9th, 2010)
  #3 (permalink)  
Old September 14th, 2010, 05:29 AM
Registered User
 
Join Date: Sep 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Speaking of the paginated list...when they first mention it in Page 106 and show the code, it's a pity that they don't display the full name space.

We've got a class file to create but not a location as to where it should be stored. If you download the text file source code this info is missing there too!

It's only half way down page 107 when the authors give us our first clue as to where to store the file!

btw: namespace NerdDinner.Helpers!

A bit of proof reading might have been helpful pre-book launch! :)

Last edited by kinvig; September 14th, 2010 at 05:37 AM.. Reason: Bad grammar!
  #4 (permalink)  
Old October 14th, 2010, 04:08 PM
Registered User
 
Join Date: Oct 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default The code examples in the book are horrible.

Did anyone proofread the NerdDinner chapters??

Code doesn't match up with text. Missing code. No namespaces in examples.

For example the Helpers folder is not even mentioned...ANYWHERE.

The download code is a waste...copy of wrong code in book.

This book is a turd with stink, flush it.

two words for you....PROOF - READ
three more...DO - NOT - BUY
  #5 (permalink)  
Old October 14th, 2010, 04:20 PM
Registered User
 
Join Date: Oct 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Free Book Offer - Reply To This Thread!

Reply to this thread if you think they should send us a voucher for a free book. This book was obviously not ready for publishing.
  #6 (permalink)  
Old October 14th, 2010, 05:51 PM
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

There's a dozen more issues after page 107. I found all the workarounds I needed in this forum, plus I added a few more I encountered.

If you run into an issue, please browse the forums for a solution or post your questions here and I'll try to help (no, I don't work for Wrox).
  #7 (permalink)  
Old October 15th, 2010, 08:04 AM
Registered User
 
Join Date: Oct 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Default parameter specifiers are not permitted

Hello,

When i try to do this:

public ActionResult Index(int page = 0) (page 107) i get the message

Default parameter specifiers are not permitted

What to do?

greetz
  #8 (permalink)  
Old October 15th, 2010, 10:09 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

@Ewi2010 Default parameters was introduced in C# 4.0. Sounds like you're not using the most updated Visual Studio. What version are you using? I'm using VS 2010 Ultimate. You should be able to use VS 2010 Express.

Get VS2010 Express, ASP.Net, ASP.NET MVC, SQL Server Express for free at http://www.asp.net/downloads

If you insist on using older C#, you might get around this by removing the default AND creating an overrided Index action method. This is not recommended.

Last edited by flyinhawaiian; October 15th, 2010 at 10:24 AM..
  #9 (permalink)  
Old October 15th, 2010, 10:11 AM
Registered User
 
Join Date: Sep 2010
Posts: 3
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Quote:
public ActionResult Index(int page = 0) (page 107)
Which IDE are you using? I beleive the default parameters are a Visual Studio 2010 feature only. If you're not using VS2010 you'll have to use:

Code:
public ActionResult Index([DefaultValue(0) int page)
{...}
  #10 (permalink)  
Old October 18th, 2010, 01:50 PM
Registered User
 
Join Date: Oct 2008
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My Dinner table only hzs 21 records.
This gets around the optional parameter prohibition and default value ( int page = 0) prohibition in VS 2008:
publicActionResult Index(paramsint[] Page)
{
int page = 0;
if (Page != null){
page = (int)Page[0];
}
const int pageSize = 3;

var upcomingDinners = dinnerRepository.FindUpcomingDinners();
var paginatedDinners = upcomingDinners.OrderBy(d => d.EventDate)
.Skip(page * pageSize)
.Take(pageSize)
.ToList();
return View(paginatedDinners);
}

Last edited by kermit1965; October 19th, 2010 at 03:46 PM.. Reason: Cleaner code








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