如何在MVC4中更改主题

Tae*_*hin 1 themes asp.net-mvc-4

好像我可以从jquery网站下载我喜欢的jquery主题来创建新的主题.但是在我的MVC网站上这并没有太大变化.谁能告诉我如何在MVC4应用程序中更改主题?

小智 5

据我了解你的问题:

如何使用jquery ui主题滚轮中的自定义生成主题替换MVC4应用程序中的基本主题?

我的步骤为我的剃刀MVC4 visual studio 2012应用程序创建了一些用于Intranet应用程序的MS标准模板.jQueryUI已经安装在我的应用程序中,其基本主题来自nuget.

  1. 使用http://jqueryui.com/themeroller/创建主题并将zip下载到某个临时文件夹
  2. 将jquery-ui-1.10.3.custom.js解压缩到我的Scripts文件夹中
  3. 在App_Start/Bundle.Config文件中编辑了我的RegisterBundles方法
    bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include("~/Scripts/jquery-ui-1.10.1.js"));
    bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include("~/Scripts/jquery-ui-1.10.3.custom.js"));
  4. 将为我的自定义主题(例如my-theme)命名的css子文件夹提取到主题文件夹"Content/themes/my-theme"中.
  5. 注释掉App_Start BundleConfig.cs中的基本主题行,并用单文件包替换大基本主题StyleBundle
    bundles.Add(new StyleBundle("~/Content/themes/my-theme/css").Include( "~/Content/themes/my-theme/jquery-ui-1.10.3.custom.css")); //bundles.Add(new StyleBundle("~/Content/themes/base/css").Include( // "~/Content/themes/base/jquery.ui.core.css", // "~/Content/themes/base/jquery.ui.resizable.css", // ...
  6. 最后用我的layout.cshtml替换了base-theme bundle调用.
    @Styles.Render("~/Content/themes/kjr-theme/css") @Styles.Render("~/Content/themes/base/css")

如果有更好或更清晰的方法来替换MVC4应用程序中的主题,请告诉我!

迈克尔