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

前端 未结 9 1934
天涯浪人
天涯浪人 2020-12-05 09:15

This is the code which I have in my partial view

@model Contoso.MvcApplication.Models.Exercises.AbsoluteArithmetic

@using(Html.BeginForm())
{
9条回答
  •  死守一世寂寞
    2020-12-05 10:02

    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

提交回复
热议问题