How to add a script in a partial view in MVC4?

You can use
@Scripts.Render("~/Scripts/my-script.js") for .js files and @Styles.Render("~/Content/my-Stylesheet.css") for css files.

Nb: it works for a particular bundle also More details – ‘http://www.asp.net/mvc/overview/performance/bundling-and-minification

it works on any sub-pages in razor including partial views.
for more info google for the usage of these helpers

Leave a Comment