Bundleconfig does not load all CSS files

Asked

Viewed 691 times

0

I am trying to load the CSS files jquery-ui.css and jquery-ui.theme.css creating a Bundles, but Bundle insists on only loading the standard CSS of ASP.NET MVC which css site.. To work, I always have to load the additional CSS files using the tag <link>. Where am I going wrong?

Bundleconfig

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        BundleTable.EnableOptimizations = true;

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                    "~/Scripts/jquery-ui-{version}.js",
                    "~/Scripts/jquery-ui.js",
                    "~/Scripts/jquery.dialogo.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*"));

        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

        bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));

        bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                    "~/Content/themes/base/jquery.ui.css",
                    "~/Content/themes/base/jquery.ui.theme.css"));
        }
}

_Layout.cshtml

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    @*<link href="~/Content/themes/base/css/jquery-ui.css" rel="stylesheet" />
    <link href="~/Content/themes/base/css/jquery-ui.theme.css" rel="stylesheet" />*@

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

</head>
<body>

    <h2>Menu Sistema</h2>

    @RenderPage("~/Views/Shared/_Menu.cshtml")

    @RenderBody()

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryui")
    @RenderSection("scripts", required: false)
</body>
</html>

CSS files

inserir a descrição da imagem aqui

1 answer

2


There is a small spelling error in your setup. Note that your Bundle is like:

bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                "~/Content/themes/base/jquery.ui.css",
                "~/Content/themes/base/jquery.ui.theme.css"));
    }

By your image, it should be:

bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                "~/Content/themes/base/css/jquery-ui.css",
                "~/Content/themes/base/css/jquery-ui.theme.css"));
    }
  • Gypsy, I made the adjustments and it didn’t work. I think there’s something else I did wrong.

  • Missed. I edited the answer. See now.

  • 1

    It worked. Thank you Gypsy!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.