Can I have/chain more than 1 _Layout pages in MVC 3? for a cshtml page?

前端 未结 3 2121
长情又很酷
长情又很酷 2021-02-19 00:37

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.

3条回答
  •  隐瞒了意图╮
    2021-02-19 01:10

    Yes, it works great. Just tell your layout page to use another layout page

    @{ Layout = "pathToMyOtherLayout"; }
    

    You can also use sections to pass through to the parent layouts. For example:

    @Section Headers {@RenderSection("Headers")}
    

提交回复
热议问题