Wrox Programmer Forums
BOOK: Beginning ASP.NET Web Pages with WebMatrix
This is the forum to discuss the Wrox book Beginning ASP.NET Web Pages with WebMatrix by Mike Brind, Imar Spaanjaars ; ISBN: 978-1-1180-5048-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET Web Pages with WebMatrix 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
Old January 1st, 2012, 06:13 AM
Authorized User
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default Chapter 4 Testing _PageStart.cshtml

Want to say here I REALLY like this book!!

Getting this error when I run Default.cshtml from the Level 1 folder at #13, page 108 Chapter 4.

NOTE: This error is generated from unaltered downloaded code after my typed in code failed...

Cannot perform runtime binding on a null reference
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderExcept ion: Cannot perform runtime binding on a null reference

Source Error:

Line 6:      var i = 0;
Line 7:      foreach(var color in Page.Colors) {
Line 8:          <p style="background-color:@color;font-family:@Page.Fonts[i];">
Line 9:              This paragraph is @color
Line 10:         </p>

Last edited by jpjamie; January 1st, 2012 at 06:18 AM..
Old January 1st, 2012, 07:56 AM
Wrox Author
Join Date: Dec 2011
Posts: 57
Thanks: 1
Thanked 19 Times in 19 Posts
Default re: Chapter 4 Testing _PageStart.cshtml

Hi Jamie,

Glad you like the book so far.

I have just downloaded the Chapter4.zip file from here: http://www.wrox.com/WileyCDA/WroxTit...-DOWNLOAD.html and without making any changes, launched Level1/Default.cshtml successfully.

You would only get the error you describe if Level1/_PageStart.cshtml is missing, or if the first line of code is commented out or has been removed. It should set the array that contains the colours:

Page.Fonts = new []{"Verdana", "Arial", "Courier New"};
The Following User Says Thank You to Mike Brind For This Useful Post:
jpjamie (January 4th, 2012)
Old January 5th, 2012, 03:32 AM
Registered User
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default The other missing part in Chapter 4 Testing _PageStart.cshtml

Hi Mike and Jamie.
First of all, I would like to thank you Mike for creating that wonderful book(Also, to Imar. )
Secondly, Jamie mentioned a missing part in the book. Thanks Jamie. And the fixing code in Jamie's problem, as Mike mentioned, is:

Page.Fonts = new []{"Verdana", "Arial", "Courier New"}

must be inserted in Level1/_PageStart. and must be like this

Layout = "~/Shared/_Layout1.cshtml";
PageData["Colors"] = new []{"LightCyan", "Gainsboro","Chocolate"};
Page.Fonts = new []{"Verdana", "Arial", "Courier New"};}

The other problem I found in Chapter 4 sample is the link code mentioned in Level1/Default.cshtml...

The book says <p><a href="/Level1/Page">Click</a> to visit Level 1</p>

but it results an error page in IE8 . the code must be like this:

<p><a href="Page">Click</a> to visit Level 1</p>

No including Level1 part...

Just wanted to remind to all grateful users

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 7: Unit Testing with the Unit Testing Framework antwarpes BOOK: Professional Application Lifecycle Management with Visual Studio 2010 3 September 25th, 2011 08:47 AM
Chapter 7 Unit Testing with the Unit Test Framework - examples blaurence46 BOOK: Professional Application Lifecycle Management with Visual Studio 2010 1 September 24th, 2011 10:07 AM
Chapter 12 - Testing our data Store Gandalf_the_Grey BOOK: Beginning ASP 3.0 2 March 18th, 2010 01:03 PM

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