p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP.NET Web Pages with WebMatrix (http://p2p.wrox.com/forumdisplay.php?f=662)
-   -   Chapter 3 Nested Layout Pages (http://p2p.wrox.com/showthread.php?t=86198)

jpjamie December 31st, 2011 03:46 PM

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>
<div id="electronics">
@Renderbody( )
</div>
<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?

jpjamie December 31st, 2011 04:36 PM

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!!

NEVER MIND! DUH!

JJ


All times are GMT -4. The time now is 07:52 AM.

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