Change Layout(Master Page) of view in ASP.NET MVC without recreate it

前端 未结 4 451
星月不相逢
星月不相逢 2021-01-31 08:08

I\'m using ASP.NET MVC 3 with Razor views. When you want to create a view you can choose a layout (master page) for your view, or leave it to choose Default (_Layout).

I

4条回答
  •  感动是毒
    2021-01-31 08:28

    In MVC3 you have _ViewStart.cshtml that stores all pages' Layout; you can change this element to change all pages' Layout or you can add new Layout element in top of target view pages in @{} block like the following to change the layout of the specific page:

    @{
        Layout = "~/Views/Shared/_newLayout.cshtml";
        ViewBag.Title = "Index";
    }
    

提交回复
热议问题