【www.bbyears.com--ASP.NET MVC】
hared/MasterPage.cshtml:
代码如下
@this.RenderSection("Head_Js", false)
@this.RenderSection("Body_Content", true)
Home/Index.cshtml:
代码如下
@{
ViewBag.Title = "ASP.NET MVC3视图占位符RenderSection使用示例";
Layout = "~/Views/Shared/MasterPage.cshtml";
}
@section Head_Js{
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
}
@section Body_Content{
<script type="text/javascript">
$(document).ready(function () {
$("#msg").html("hello,section.");
});
</script>
}