I have a layout page and some pages that use it. But I want to implement a navigation control on some of the sub-pages that use it. So I want to use another nested layout page. Is this possible?
相关问题
- MVC-Routing,Why i can not ignore defaults,The matc
- Entity Framework throws exception - Network Relate
- parameters in routing do not work MVC 3
- Slow loading first page - ASP.NET MVC
- There is no ViewData item with the key 'taskTy
相关文章
- “Dynamic operations can only be performed in homog
- How to get a list of connected clients on SignalR
- How do you redirect to the calling page in ASP.NET
- Change color of bars depending on value in Highcha
- The program '[4432] iisexpress.exe' has ex
- ASP.Net MVC 4 Bundles
- How to get server path of physical path ?
- Cannot implicitly convert Web.Http.Results.JsonRes
Yes, it works great. Just tell your layout page to use another layout page
You can also use sections to pass through to the parent layouts. For example:
You can chain pages just like you can Master Pages, in _ViewStart.cshtml you will see how the layout page is defined:
You can just add this section in the _Layout.cshtml to reference another parent, or add it to an individual view to reference a different layout view.
ScottGu has a post with more info on Razor Layouts
I use this exact method for what you are talking about on some ecommerce sites, where you are in the checkout process I do not want any distractions (navigation, etc) within the view, so instead of having some special case
if checkout
in layout, I make aLayoutBrandingOnly
and aLayout
which "inherits" from it so I don't have to repeat all the branding html.You can solve this easily enough in one layout page by using sections. check http://weblogs.asp.net/scottgu/archive/2010/12/30/asp-net-mvc-3-layouts-and-sections-with-razor.aspx