更改视图布局(母版页)在ASP.NET MVC中没有重新创建 [英] Change Layout(Master Page) of view in ASP.NET MVC without recreate it
问题描述
我使用ASP.NET MVC 3剃须刀意见。当你想创建一个视图,你可以选择你的视图布局(母版页),或将其选择默认(_layout)。
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 am interesting in to change this layout after create a view without recreate it, is there any where to store the layout information about the views? and how can I change it?
推荐答案
在MVC3你有 _ViewStart.cshtml
存储所有网页的布局;你可以改变这个元素来改变所有网页的布局也可以在目标视图页面顶部 @添加布局元素{}
阻止类似如下改变布局具体的页面:
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";
}
这篇关于更改视图布局(母版页)在ASP.NET MVC中没有重新创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!