Is there any way to load Script or CSS that is placed in Buddles in ASP.NET only in a single View?

0

Generally when I download the plug-in in Visual Studio in NuGet, it is necessary to put script and css in Buddles however these scripts are loading in all my Views even those that are not using, so I wonder if there is any way put these Scripts directly in the View, because without putting Buddles in Visual studio, the plugins do not work.

    
asked by anonymous 07.10.2017 / 21:10

1 answer

0

Yes.

References placed in the BundleConfig do not necessarily have to load on all pages. You can determine which page you want to put the script in as follows:

_Layout.cshtml

Edit.cshtml

In the example above, four references were included in the BundleConfig (jquery, bootstrap, jqueryval, and jsTree). In the _Layout.cshtml I'm only using the jquery and bootstrap references, and on the Edit page I'm using the jqueryval and jstree references.

In this way, the scripts referenced in the Edit page will only load when you enter it.

    
20.10.2017 / 13:04