How to include a css stylesheet in Orchard module?

自古美人都是妖i 提交于 2019-12-06 03:34:28

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/13719909/how-to-include-a-css-stylesheet-in-orchard-module

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!