首先,在项目中已经有了一个全站公用的布局页:
/Views/Shsred/_Layout.cshtml
在部分页面中需要使用一个局部的布局页,就考虑利用布局页的嵌套,几经尝试后,总结方法如下:
1、在/Views/Shsred/文件夹下建立这个局部的布局页:
/Views/Shsred/_LocalLayout.cshtml
在_LocalLayout.cshtml中加上以下代码,指定自己的布局页为/Views/Shsred/_Layout.cshtml,并在合适的位置上加上@RenderBody()命令:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}<div class="main">
<div class="left_pan" style="float:left">
<dl >点点更健康