ASP.NET MVC 4目录的捆绑和缩小



我当前正在使用MVC 4.0和Igniteui ..创建一个项目。我正在尝试捆绑Ignite UI的所有文件...因此,我已经在Web配置文件中设置了此

 <system.web>
 <compilation debug="false" targetFramework="4.0" />

我的bundlesconfig.cs

using System.Web;
using System.Web.Optimization;
namespace LicenciamentoMVC
{
public class BundleConfig
{
    // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));
        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                    "~/Scripts/jquery-ui-{version}.js"));
        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*"));
        //BundleTable.EnableOptimizations = true;
        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));
        //bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
        bundles.Add(new StyleBundle("~/Content/css").IncludeDirectory("~/Content/","*.css",true));
        bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                    "~/Content/themes/base/jquery.ui.core.css",
                    "~/Content/themes/base/jquery.ui.resizable.css",
                    "~/Content/themes/base/jquery.ui.selectable.css",
                    "~/Content/themes/base/jquery.ui.accordion.css",
                    "~/Content/themes/base/jquery.ui.autocomplete.css",
                    "~/Content/themes/base/jquery.ui.button.css",
                    "~/Content/themes/base/jquery.ui.dialog.css",
                    "~/Content/themes/base/jquery.ui.slider.css",
                    "~/Content/themes/base/jquery.ui.tabs.css",
                    "~/Content/themes/base/jquery.ui.datepicker.css",
                    "~/Content/themes/base/jquery.ui.progressbar.css",
                    "~/Content/themes/base/jquery.ui.theme.css"));
        bundles.Add(new StyleBundle("~/bundles/cssFiles").IncludeDirectory("~/Content/CssIgniteUI/", "*.css", true));
        bundles.Add(new ScriptBundle("~/bundles/jsFiles").IncludeDirectory("~/Scripts/js/", "*.js", true));
    }
 }
}

,然后在我要放这个的情况下,在这种情况下,index.cshtml

@{
ViewBag.Title = "Index";
}
@Styles.Render("~/bundles/cssFiles")
@Scripts.Render("~/bundles/jsFiles")
<h2>Index</h2>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

我的文件目录是这样的:项目

-Content
    --CssIgniteUI(Css files of igniteui)
    --themes(default theme css files of asp.net project)
    --Site.css
  -Scripts
    --js(folder containing the js files from igniteui)
    --all the files that come with the default theme of the project

当我尝试打开客户端控制器...它给我错误...我想念什么?页面doenst出现在浏览器上..我正在使用firebug查看文件...但是nthing显示了..

预先感谢..

我认为您可能会缺少JQuery UI,因为ASP.NET MVC4仅默认添加JQuery Bundle。IGNITE UI所需资源的正确顺序看起来像:

In _Layout.cshtml:
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@RenderSection("scripts", required: false)

,然后直接在脚本部分包裹的视图下方或视图中:

@section scripts{
    @Scripts.Render("~/bundles/jsFiles")
    <!--Ignite UI related script(control definitions) go here-->
}

基本上,jQuery jQuery UI需要在IGNITE UI脚本之前加载。您可以在添加必需的资源文档和几乎所有样本中看到,所以我建议您在入门时将其用作参考。

在旁注上,包括jQuery UI CSS("〜/content/themes/"中的MVC4中包含的基本主题),因为IGNITE UI主题CSS文件也是自定义的JQuery UI主题。

最新更新