MVC5 ActionLink Styles.Render Scripts.Render

ActionLink的作用是Controller的触发。其写法参数如下:

@Html.ActionLink("页面显示名称","Controller的ActionName","ControllerName","Action's parameter",当前按钮CSS样式)

--------------------------------------------------------------------------------------------------------------------------------------------------------------

Styles.Render和Scripts.Render后面的参数都是虚拟路径。该路径是在App_Start中进行配置的。作用是引入js和css.

@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")

App_Start中的BundleConfig.cs

bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));
bundles.Add(new StyleBundle("~/Content/css").Include(
                      "~/Content/bootstrap.css",
                      "~/Content/site.css"));

Include中的路径是项目中相对路径。ScriptBundle中的路径是虚拟路径,与页面中的设置保持一致即可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章