0

I have downloaded the Metro CSS via Bower by including it in the Bower.json file:

"metro-ui-css": "3.0.13"

This appears to install the Metro stuff under /wwwroot/lib/metro-ui-css/build/css and also /fonts and /less folders. I have included the following references in my _Layout.cshtml file:

<environment names="Development">
<link rel="stylesheet" href="~/lib/metro-ui-css/build/css/metro.css">

And under the <head> section::

<environment names="Development">
<script src="~/lib/metro-ui-css/build/js/metro.js"></script>

But no matter which Metro class I try to include in a View .cshtml file the Classes will not appear. Any idea what I am doing wrong and how I can get them to display?

Many thanks

Mr Lister
  • 45,515
  • 15
  • 108
  • 150

1 Answers1

1

Create a new Bundle

In the 'App_Start' folder of your solution, find the 'BundleConfig.cs' file and open it. Here you can add a new bundle, for example:

bundles.Add(new ScriptBundle("~/bundles/metroJs").Include(
                "~/Scripts/metroJs.js"));

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

Your paths to the .js and .css files may be different, however this may also be correct.

Once you've done that, go back to your '_Layout.cshtml' file and at the bottom you'll more than likely already have some '@Scripts.Render()'. Just add one with the name of the new bundle you just created like so:

@Scripts.Render("~/bundles/metroJs")
@Styles.Render("~/Content/metroJs")
MalvEarp
  • 525
  • 2
  • 5
  • 19
  • Hi,Unfortunately under ASP.NET 5 and MVC 6 there is no App_Start folder and no BundleConfig.cs. They must have been moved somewhere else but I'm not sure where: any thoughts? – Jeremy Britton Dec 16 '15 at 16:39
  • @JeremyBritton This answer/thread may be of use: http://stackoverflow.com/a/19038935/1489570 – MalvEarp Dec 16 '15 at 16:52
  • @MalvEarp You can't add a css file to a ScriptBundle (like you wrote in your answer). The css must go into a `StyleBundle` that will then be added with `@Styles.Render("~/bundles/whatever"); – Michaël Polla Jan 14 '19 at 09:28
  • @MichaëlPolla Correct, I must not have been concentrating completely when writing the example. – MalvEarp Jan 14 '19 at 09:36