Using scripts in a master page with ASP.NET MVC

前端 未结 11 1313
难免孤独
难免孤独 2020-11-28 19:06

I\'m fairly new to ASP.NET MVC, and I\'m having a little trouble with scripts... in particular, I want to use jQuery in most pages, so it makes sense to put it in the master

11条回答
  •  遥遥无期
    2020-11-28 19:28

    Based on the other replies, perhaps an extension method on Html (which is very common for MVC), similar to Eduardo's answer:

     <%=Html.Script("~/Scripts/jquery-1.2.6.js")%>
    

    With:

    public static string Script(this HtmlHelper html, string path)
    {
        var filePath = VirtualPathUtility.ToAbsolute(path);
        return "";
    }
    

提交回复
热议问题