We are making a .Net MVC websolution that is going to be using widgets rendered as HTML.Partials(). We would like to be able for the partial view to add its dependencys in the main page views scripts tags, both css-files as well as javascript files.
Ive been trying with this code in my partial. But the js-file isnt rendered in the layout section of my page. What is wrong?
@{
var bundle = System.Web.Optimization.BundleTable.Bundles.GetRegisteredBundles()
.Where(b => b.Path == "~/bundles/jquery")
.First();
bundle.Include("~/Scripts/addtojquerybundletest.js");
}
See Question&Answers more detail:os