I am working on a module for Orchard, and I just want to know how to include a css file.
I have done the following with no result:
Added a folder "Styles" to the root of my module and included a stylesheet and a Web.config file like in this question.
And I have seen this but that's not what I am looking for.
EDIT:
Ok, solution:
When I started working on Orchard I created a new module by just creating a new project in Orchard.Web/Modules
folder, but as I read here, my Views/Web.config
file has to include some orchard base things what mine didn't because I did not create the module using codegen. I fixed it now by replacing my Web.config
file for a Web.config
file from another Orchard module, now it works.
Next time I will use codegen to create a new module.
Thanks to endorphin for helping me!
If you want to include your stylesheet in a view, you need to specify this at the top of your view. Where the name of your stylesheet is the filename of the .css file in the Styles folder.
So in your .cshtml file for your view..
@{
Style.Include("your-stylesheet.css").AtHead();
}
I have used AtHead()
in the past, but there are other methods to include your stylesheet in different locations (such as AtFoot()
)
If your stylesheet depends on other stylesheets you can do something a little more interesting by creating a Resource Manifest which is detailed here https://stackoverflow.com/a/6500121/580101
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With