How to include bundling in spark layout files in ASP.NET MVC?

112 Views Asked by At

I have defined bundles and I am trying to use them in my spark layout with the following syntax.

${Scripts.Render("~/bundles/jqueryPlugins")}
${Scripts.Render("~/bundles/jqGridJqueryPlugins")}
${Scripts.Render("~/bundles/jqPlotJqueryPlugins")}

I am getting the following error

Dynamic view compilation failed.
The name 'Scripts' does not exist in the current context
The name 'Scripts' does not exist in the current context
The name 'Scripts' does not exist in the current context

Its not working. What is the correct syntax for this ?

Also whats the syntax to include references on the page ? Like in razor we use @using Blah.Blah

1

There are 1 best solutions below

0
Dave Thieben On

The Scripts and Styles classes are static objects in the System.Web.Optimization namespace, so all you need to do is reference this namespace and you can use them. add this to the spark section in your Web.config:

<add namespace="System.Web.Optimization" />

and then you can do:

${Scripts.Render("~/js/jquery")}
${Scripts.Render("~/js/jqueryval")}
${Scripts.Render("~/js/application")}
<use content="scripts"/>