我使用 Visual Studio 2012 和内置模板(在“添加”->“新建项目”下)创建了一个全新的 ASP.NET Web 窗体 Web 应用程序项目。在默认提供的 Site.Master 页面中,我看到一些针对 JQuery 的标记,这些标记包含在下面。
给定以下标记,ASP.NET 如何找出包含 JQuery 所需的路径?
<asp:ScriptManager runat="server">
<Scripts>
<%--Framework Scripts--%>
<asp:ScriptReference Name="MsAjaxBundle" />
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="jquery.ui.combined" />
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</asp:ScriptManager>
我没有在任何地方看到可以将 jquery 解析为“~/Scripts/jquery-1.7.1.js”的配置文件或代码。我看到一个packages.config 文件,但它没有明确描述必须以某种方式计算的路径。
有人知道 JQuery 的 javascript 文件的路径在运行时是如何解析的吗?
请您参考如下方法:
在 Microsoft.ScriptManager.WebForms PreAppStartCode 中,它具有:
System.Web.UI.ScriptManager.ScriptResourceMapping.AddDefinition("WebFormsBundle", new ScriptResourceDefinition
{
Path = "~/bundles/WebFormsJs",
CdnPath = "http://ajax.aspnetcdn.com/ajax/4.5/6/WebFormsBundle.js",
LoadSuccessExpression="window.WebForm_PostBackOptions",
CdnSupportsSecureConnection = true
});
这是连接到脚本引用中的声明的内容:
<asp:ScriptReference Name="WebFormsBundle" />
并且还会进行重复数据删除,因为 ScriptReference 路径与 bundle 内的文件路径相同,这些文件应在 BundleConfig.cs 内注册
