View Single Post
  #1 (permalink)  
Old December 31st, 2011, 03:46 PM
jpjamie jpjamie is offline
Authorized User
Points: 313, Level: 6
Points: 313, Level: 6 Points: 313, Level: 6 Points: 313, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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>
<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?

Last edited by jpjamie; December 31st, 2011 at 03:51 PM.. Reason: Discovery
Reply With Quote