MVC笔记-模板页布局
MVC分区后 要加上Ares下的主目录 如:@Html.ActionLink("这个帖子真奇葩", "HotIndex", "Proscenium/PostTemplate") <span class="badge">50</span></th>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@RenderSection("header", required: false) <!-- 子页插入到head的入口。相当于母版页里的ContentPlaceHolder -->
@{Html.RenderAction("LoginInfo", "Partial");} <!-- 登录信息。相当于用户控件 -->
@{Html.RenderAction("Navi", "Partial", new { parentController = ViewContext.RouteData.Values["controller"].ToString() });}<!-- 导航条。相当于用户控件 -->
@RenderBody() <!-- 输出嵌套页 -->
@Html.Partial("~/Views/Shared/_Web_Top.cshtml")
<script type="text/javascript"
src="@Url.Content("~/App_Themes/Scripts/Jquery/plugin/jquery.artDialog/artDialog.js?skin=icons")"></script>
<title>@(ViewBag.Title == null ? "网站默认标题" : ViewBag.Title)</title>
<meta name="Keywords" content="@(ViewBag.Keywords == null ? "网站默认关键字" : ViewBag.Keywords)" />
<meta name="Description" content="@(ViewBag.Description == null ? "网站默认关键字" : ViewBag.Description)" />
<link href="@Url.Content("~/Content/Css/Product.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Scripts/Common/Common.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery-1.6.2.min.js")"></script>
@RenderSection("Head", required: false)
子母版页_SingleContent_Layout.cshtml
@section header{ @Styles.Render("~/Content/SingleContent") @* 这是本子布局页的子页插入内容的入口,注意到没?它写在本子布局页插入母版页的入口处*@ @RenderSection("header", required: false) }
@section Scripts { @RenderSection("scripts", required: false) }
@{Html.RenderPartial("_PartialHander", new List<string> { "aaa","bbb","ccc"});}@*调用分布视图,分布视图不需要有Controller*@
@model List<string> 给model类型,这时候Model就是一个对象集合
@foreach (var item in Model){
<li>@item</li>
}
@{Html.RenderPartial("_PartialFoot");}
模板页
<div>
@{Html.RenderPartial("_PartialHander", new List<string> { "aaa","bbb","ccc"});}@*调用分布视图*@
</div>
<div>
@RenderBody()
</div>
<div>
@{Html.RenderPartial("_PartialFoot");}
</div>