發(fā)表日期:2019-04 文章編輯:小燈 瀏覽次數(shù):3055
很多時(shí)候模板中我們需要用到不用母版頁(yè),那么如何在模板中引用不同母版頁(yè)呢?
1、_ViewStart.cshtml中聲明,代碼如下:@{ ????Layout?="_LayoutCustom..cshtml"; }
模板Views目錄中默認(rèn)有一個(gè)全局的_ViewStart.cshtml文件,對(duì)當(dāng)前目錄或下級(jí)的所有目錄生效,如果我們某個(gè)子目錄中需要用到不同母版頁(yè),可以自行在目錄中添加_ViewStart.cshtml文件來(lái)設(shè)置,優(yōu)先級(jí)為子目錄中的設(shè)置優(yōu)先于父級(jí)目錄中的設(shè)置。
2、在模板中重寫(xiě)Layout,代碼和方法1一樣:
@{ ????Layout?="_LayoutCustom.cshtml"; }
如果模板中不重寫(xiě)Layout參數(shù),那么默認(rèn)繼承當(dāng)前目錄或上級(jí)目錄的_ViewStart.cshtml文件中的設(shè)置。
日期:2019-04 瀏覽次數(shù):3187
日期:2019-04 瀏覽次數(shù):3175
日期:2019-04 瀏覽次數(shù):3081
日期:2019-04 瀏覽次數(shù):2901
日期:2019-04 瀏覽次數(shù):2997
日期:2019-04 瀏覽次數(shù):3152
日期:2019-04 瀏覽次數(shù):3097
日期:2019-04 瀏覽次數(shù):3359
日期:2019-04 瀏覽次數(shù):3421
日期:2019-04 瀏覽次數(shù):3054
日期:2019-04 瀏覽次數(shù):3444
日期:2019-04 瀏覽次數(shù):2855
日期:2019-04 瀏覽次數(shù):2996
日期:2019-04 瀏覽次數(shù):3115
日期:2019-04 瀏覽次數(shù):2963
日期:2019-04 瀏覽次數(shù):3409
日期:2019-04 瀏覽次數(shù):3328
日期:2019-04 瀏覽次數(shù):2993
日期:2019-04 瀏覽次數(shù):3227
日期:2019-04 瀏覽次數(shù):3055
日期:2019-04 瀏覽次數(shù):2818
日期:2019-04 瀏覽次數(shù):3124
日期:2019-04 瀏覽次數(shù):3024
日期:2019-04 瀏覽次數(shù):3115
日期:2019-04 瀏覽次數(shù):3078
日期:2019-04 瀏覽次數(shù):2951
日期:2019-04 瀏覽次數(shù):2799
日期:2019-04 瀏覽次數(shù):2807
日期:2019-04 瀏覽次數(shù):2875
日期:2019-04 瀏覽次數(shù):2896
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.