在ASP.NET Web Forms 4.5中绑定JQuery
我使用Visual Studio 2012和内置模板(在添加->新建项目下)创建了一个全新的ASP.NET Web表单Web应用程序项目。在默认情况下提供的Site.Master页面中,我看到一些针对JQuery的标记,如下所示 考虑到以下标记,ASP.NET如何计算出包含JQuery所需的路径在ASP.NET Web Forms 4.5中绑定JQuery,jquery,asp.net,visual-studio-2012,webforms,bundling-and-minification,Jquery,Asp.net,Visual Studio 2012,Webforms,Bundling And Minification,我使用Visual Studio 2012和内置模板(在添加->新建项目下)创建了一个全新的ASP.NET Web表单Web应用程序项目。在默认情况下提供的Site.Master页面中,我看到一些针对JQuery的标记,如下所示 考虑到以下标记,ASP.NET如何计算出包含JQuery所需的路径 <asp:ScriptManager runat="server"> <Scripts> <%--Framework Scripts--%>
<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
});
这是从脚本引用连接到声明的内容:
重复数据消除也是如此,因为ScriptReference路径与bundle中的文件路径相同,这些文件应该在BundleConfig.cs中注册。您的解决方案中的某个地方没有“scripts”文件夹吗?在这里看看您的另一个问题:我想答案似乎提供了一些澄清。答案似乎表明,软件包将jQuery文件放入脚本文件夹,然后在运行时从那里自动添加,而无需进一步引用。简:是的,我确实有一个脚本文件夹,其中包含所有jQuery javascript文件。。。但我的问题是这个目录的路径是如何生成的。。。我很难理解这里提供的答案,所以我想我至少可以自己解决这个问题,并试图弄清楚。我现在知道,默认情况下,Web表单项目(显然)安装了用于JQuery的NuGet包。我在该项目的参考资料中看到了它们。我想我在某个地方看到了一个基本的jQueryUI主题包。。。。因此,升级到自定义下载的JQuery UI有点困难,请单击“打包”。。。我不确定我是否应该删除JQuery NuGet包…对于想知道它在哪里的人,如果您反映
Microsoft.ScriptManager.WebForms.dll
它在Start()
方法中。我仍然不明白为什么您将webformsbundle放在BundleConfig.cs和ScriptManager中。你说这是为了“重复数据消除”,但这是什么意思?什么的重复数据消除?为什么它被定义了两次。这似乎很可笑。