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 December 31st, 2011, 03:46 PM
Authorized User
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default Chapter 3 Nested Layout Pages

Nesting Layout Pages (TRY IT OUT starting page 62)

MainLayout.cshtml will run referencing (using) _MainLayout.cshtml just fine, however both Automation.cshtml and Electronics.cshtml give me the error: "name 'Renderbody' does not exist in the current context."

I suspect it's an "obvious" file linking error I'm just missing, because MainLayout.cshtml runs just fine, so why can't the other two find @Renderbody? I also suspect MainLayout.cshtml runs because it has more HTML code to RENDER the page than the other two, which might be part of my problem.

I found errata on page 64 in #8 where there's a missing semicolon at the end of "Layout...cshtml";" That fixed and asside, I cannot otherwise seem to figure out what's wrong here.

Here's a copy and paste of my code for _ElectronicsLayout.cshtml, ...

Layout = "~/Shared/_MainLayout.cshtml";

<div id="electronicsnav">
<a href="Products">Products</a> <br/>
<a href="Services">Services</a> <br/>
<a href="Support">Support</a> <br/>
<a href="Team">Team</a> <br/>
<div id="electronics">
@Renderbody( )
<div id="footer">The Electronics Division Footer</div>


Here's the code for Electronics.cshtml which references _ElectronicsLayout.cshtml (above code)...


Layout = "~/Shared/_ElectronicsLayout.cshtml";
Page.Title = "Electronics";
<h3>Electronics Home Page</h3>

Added here after initial posting!
Could it be that Automation.cshtml and Electronics.cshtml are looking for Page.title?

Last edited by jpjamie; December 31st, 2011 at 03:51 PM.. Reason: Discovery
Old December 31st, 2011, 04:36 PM
Authorized User
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default UpperCaseMatters

I figured it all out and I'm embarrassed to say it was @RenderBody() NOT @Renderbody() that caused all my problems. I knew it wasn't a code/logic problem and something I just was missing.

Now I have a few hours out of my life missing as well!!



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Nested master pages SouthendSupporter ASP.NET 3.5 Basics 1 March 3rd, 2011 10:15 AM
Problem in nested master pages. harsh.kintu ASP.NET 2.0 Professional 2 January 9th, 2007 10:04 AM
strange "errors" with nested master pages... thenoseknows ASP.NET 2.0 Professional 2 November 28th, 2006 05:28 PM
Chapter 5 - Try It Out: Pages 208-210 Wyatt70 BOOK: Beginning XML 3rd Edition 5 November 22nd, 2006 06:54 AM
Chapter 9 Protecting Your Pages malhyp Dreamweaver (all versions) 1 August 20th, 2005 04:14 AM

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