Matthew Grima
Matthew Grima

Reputation: 1523

MVC - Have View affect sections of main layout

I've created a layout with all the styling etc. I have a menu and sub menu here, also a 3 column layout for content.

The left column will be used as a filter for reports most of the time, center for main content and the right column for help tips depending on the view you're at.

Can I define what the links in the sub menu are?

What is populated in the Left and Right columns, depending on the current view?

Upvotes: 0

Views: 138

Answers (1)

MisterJames
MisterJames

Reputation: 3326

If you're looking to add new content in those areas, you want to be looking at sections.

You can see an example of this in the default project, just do a file-new-project to check out the layout page. You'll want something like this in your layout:

@RenderSection("SideBar", false)

The false here lets you opt-out of putting sidebar content on a view.

Your view would then have something like this:

@section SideBar {
   // your sidebar stuff
}  

As always, the Gu knows best: http://weblogs.asp.net/scottgu/archive/2010/12/30/asp-net-mvc-3-layouts-and-sections-with-razor.aspx

Cheers.

Upvotes: 1

Related Questions