5

我使用Visual Studio 2012和内置模板(在Add - > New Project下)创建一个全新的ASP.NET Web Forms Web应用程序项目。在默认情况下提供的Site.Master页面中,我看到了一些针对JQuery的标记,它包含在下面。在ASP.NET Web Forms 4.5中绑定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“〜/脚本/ jQuery的1.7.1.js”。我看到一个packages.config文件,但它没有明确描述必须以某种方式计算的路径。

有谁知道如何在运行时解决JQuery的JavaScript文件路径?

+0

你的解决方案中没有“脚本”文件夹吗? – Thousand

+0

看看你在这里的其他问题:http://stackoverflow.com/questions/12290537/vs2012-web-forms-bundling- confusion答案似乎提供了一些澄清,我认为。答案似乎表明,这些包将jQuery文件放置到脚本文件夹中,然后在运行时从那里自动添加这些文件,而无需进一步引用。 – Nope

+0

简:是的我有一个脚本文件夹w /所有的jQuery JavaScript文件在那里......但我的问题是如何生成此目录的路径。 – ClearCloud8

回答

2

里面的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路径与BundleConfig.cs中应注册的文件的路径相同

+2

对于任何人想知道这是什么,如果你在'Start()'方法中反映'Microsoft.ScriptManager.WebForms.dll'。 – maxp

+0

我还是不明白你为什么在BundleConfig.cs和ScriptManager中有webformsbundle。你说它是用于“重复数据删除”,但这是什么意思?重复删除什么?为什么定义两次。这似乎很可笑。 – Matt

相关问题