发表日期:2019-04 文章编辑:小灯 浏览次数:2385
和普通模板页一样,局部页也需要保存为.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 浏览次数:2589
日期:2019-04 浏览次数:2508
日期:2019-04 浏览次数:2414
日期:2019-04 浏览次数:2283
日期:2019-04 浏览次数:2361
日期:2019-04 浏览次数:2505
日期:2019-04 浏览次数:2473
日期:2019-04 浏览次数:2730
日期:2019-04 浏览次数:2792
日期:2019-04 浏览次数:2440
日期:2019-04 浏览次数:2716
日期:2019-04 浏览次数:2249
日期:2019-04 浏览次数:2399
日期:2019-04 浏览次数:2521
日期:2019-04 浏览次数:2366
日期:2019-04 浏览次数:2820
日期:2019-04 浏览次数:2684
日期:2019-04 浏览次数:2385
日期:2019-04 浏览次数:2609
日期:2019-04 浏览次数:2434
日期:2019-04 浏览次数:2209
日期:2019-04 浏览次数:2472
日期:2019-04 浏览次数:2414
日期:2019-04 浏览次数:2501
日期:2019-04 浏览次数:2475
日期:2019-04 浏览次数:2290
日期:2019-04 浏览次数:2223
日期:2019-04 浏览次数:2218
日期:2019-04 浏览次数:2286
日期:2019-04 浏览次数:2318
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.