巧用section在cshtml写入layout中写入head信息 ASP.NET MVC

来源:岁月联盟 编辑:exp 时间:2012-05-09

layout文件中:

<head>
<meta charset="utf-8" />
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
@RenderSection("head", false)
</head>
 cshtml模板文件中:

@section head
{
<script type="text/javascript"">
   //Your java script here
</script>
}

 


摘自 阿旭博客