ASP.NET MVC3.0 中 Razor 母版嵌套

_Layout.cshtml   主母版

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <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)
</head>
<body oncontextmenu=self.event.returnValue=false onselectstart="return false">
    @RenderBody()
</body>
</html>

_Layout_Local.cshtml  子母版

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Head{
    @RenderSection("Head", required: false)
    <script type="text/javascript" src="@Url.Content("~/App_Themes/Scripts/Jquery/plugin/jquery.artDialog/artDialog.js?skin=icons")"></script>
}
@Html.Partial("~/Views/Shared/_Web_Top.cshtml")
<div class="top_ad">
    <a href="/Activity/201206/index.html" target="_blank"><img src="/Content/testimg/ad_201206.jpg" alt="" title="" width="960" height="121" /></a>
</div>
<div class="head">
    <div class="head_left">
        <a href="/">
            <img src="/Content/images/logo.png" width="192" height="71" /></a></div>
    <div class="head_right">
        <li>
            <img src="/Content/images/head_text_02.png" /></li>
        <li>
            <img src="/Content/images/head_text_01.png" /></li>
        <li>
            <img src="/Content/images/head_text_tel.png" /></li>
    </div>
</div>
<div class="clear">
</div>
@RenderBody()
<div class="clear">
</div>
@Html.Partial("~/Views/Shared/_Web_Bottom.cshtml")

index.cshtml  内容页

@{
    ViewBag.Title = "新标题";
    ViewBag.Description = "新注释";
    Layout = "~/Views/Shared/_Layout_Local.cshtml";
}
@section Head{
    <link rel="stylesheet" type="text/css" href="/Content/Activity/Mobile/style.css" />
    <script type="text/javascript" src="/Content/Activity/Mobile/jscript.js"></script>
}
<div id="Content02" class="content" style="display:none;" >
    <img src="/Content/Activity/Mobile/title.gif" />
    <img src="/Content/Activity/Mobile/banner.jpg" />
    <div class="Form" style="height:250px;">
        <ul>
            <li>
                <input name="C_Phone" id="C_Phone" type="text" value="请输入接收短信的手机号码" onclick="if($(this).val()=='请输入接收短信的手机号码'){$(this).val('')}" class="input" maxlength="11" /></li>
            <li>
                <input name="" type="image" src="/Content/Activity/Mobile/Submit.png" onclick="return chktop2();"
                style="float: left; margin-left: 20px;" /></li>
        </ul>
    </div>
</div>

  

posted @ 2012-06-12 09:10  AIの海雅  阅读(3569)  评论(1编辑  收藏  举报