How can I include css files from an MVC partial control?

后端 未结 9 1588
南笙
南笙 2020-12-28 09:15

I\'m using ASP.NET MVC and I have a partial control that needs a particular CSS & JS file included. Is there a way to make the parent page render the script

9条回答
  •  庸人自扰
    2020-12-28 09:39

    Sorry, you cannot from a partial control refer "up" to something in the parent page (or add anything). The only communication is "down" from the parent to the partial by passing the ViewData / Model.

    You are describing functionality of a master page and a normal page using the content place holders, but partial controls do not function like that.

    But, if I am not mistaken, you can just physically add the script or link tags to the actual parent page that you render the partial page on - the CSS should be used by the partial page as well.

提交回复
热议问题