发表日期:2019-04 文章编辑:小灯 浏览次数:2386
和普通模板页一样,局部页也需要保存为.cshtml后缀,局部页面可以保存在Views/Model或Views/Shared目录下,模板中通过Html.Partial方式加载,这两个目录用法都一样,
局部页面命名规范建议为*Partial.cshtml。如下图:
如上图的TopPartial.cshtml保存页面顶部的html代码,在母版页或模板页可以通过Html.Partial方式加载,示例代码:
@{string templateDirectory = Html.TemplateDirectory();}<!DOCTYPE html> <html> <head> <title>@Html.Title()</title> <meta name="keywords" content="@Html.Keywords()" /> <meta name="description" content="@Html.Description()" /> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=0,minimal-ui" /> <meta name="format-detection" content="telephone=no" /> <meta name="renderer" content="webkit" /> <link rel="stylesheet" href="@templateDirectory/Css/style.css" /> <script src="@templateDirectory/Js/basic.js"></script> </head> <body> @Html.Partial("TopPartial") @RenderBody() @Html.Partial("FooterPartial") </body> </html>
日期:2019-04 浏览次数:2591
日期:2019-04 浏览次数:2511
日期:2019-04 浏览次数:2416
日期:2019-04 浏览次数:2285
日期:2019-04 浏览次数:2366
日期:2019-04 浏览次数:2507
日期:2019-04 浏览次数:2475
日期:2019-04 浏览次数:2733
日期:2019-04 浏览次数:2795
日期:2019-04 浏览次数:2443
日期:2019-04 浏览次数:2721
日期:2019-04 浏览次数:2252
日期:2019-04 浏览次数:2402
日期:2019-04 浏览次数:2523
日期:2019-04 浏览次数:2367
日期:2019-04 浏览次数:2823
日期:2019-04 浏览次数:2687
日期:2019-04 浏览次数:2386
日期:2019-04 浏览次数:2612
日期:2019-04 浏览次数:2437
日期:2019-04 浏览次数:2211
日期:2019-04 浏览次数:2475
日期:2019-04 浏览次数:2416
日期:2019-04 浏览次数:2503
日期:2019-04 浏览次数:2477
日期:2019-04 浏览次数:2292
日期:2019-04 浏览次数:2226
日期:2019-04 浏览次数:2222
日期:2019-04 浏览次数:2286
日期:2019-04 浏览次数:2319
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.