Add CSS references to page's <head> from a partial view

后端 未结 6 2359
感动是毒
感动是毒 2021-02-20 02:21

Is there a way to add CSS references to a page from a partial view, and have them render in the page\'s (as required by the HTML 4.01

6条回答
  •  再見小時候
    2021-02-20 02:52

    You could also use the Telerik open source controls for MVC and do something like :

    <%= Html.Telerik().StyleSheetRegistrar()
                      .DefaultGroup(group => group
                         .Add("stylesheet.css"));
    

    in the head section and

    <%= Html.Telerik().ScriptRegistrar()
                      .DefaultGroup(group => group
                         .Add("script.js"));
    

    in the script section at the botttom of your page.

    And you can keep adding scripts on any view , or partial view and they should work.

    If you don't want to use the component you can always inspire yourself from there and do something more custom.

    Oh, with Telerik you also have options of combining and compressing the scripts.

提交回复
热议问题