如何一次在多个页面中设置布局页面 [英] How to set layout page in multiple pages at once

查看:301
本文介绍了如何一次在多个页面中设置布局页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



假设我有30页重复页眉和页脚。现在我想在布局页面中移动页眉和页脚,并立即在每个页面中设置布局属性,而无需复制和粘贴。任何人都可以建议如何这样做。谢谢

Hi,
suppose I have 30 pages with repeating header and footer. Now I want to shift the header and footer in layout page and set the layout attribute in each page at once without copy and paste. Can any one please suggest how to do so. Thanks

推荐答案

在名为 _ViewStart.cshtml的 Views 文件夹中创建一个文件(或 _ViewStart.vbhtml 用于VB.NET项目)。在该文件中设置布局,它将适用于所有视图。



ASP.NET MVC 3:使用Razor布局| ScottGu的博客 [ ^ ]



注意:如果每个视图文件中都有页眉和页脚,则必须单独编辑每个文件删除它们。
Create a file in the Views folder called _ViewStart.cshtml (or _ViewStart.vbhtml for a VB.NET project). Set the layout in that file, and it will apply to all views.

ASP.NET MVC 3: Layouts with Razor | ScottGu's Blog[^]

NB: If you already have the header and footer in each view file, then you'll have to edit each file individually to remove them.


这篇关于如何一次在多个页面中设置布局页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆