加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

在ASP.NET Web Forms 4.5中捆绑JQuery

发布时间:2020-12-16 03:22:07 所属栏目:asp.Net 来源:网络整理
导读:我使用Visual Studio 2012和内置模板(在Add – New Project下)创建一个全新的ASP.NET Web Forms Web应用程序项目.在默认情况下提供的Site.Master页面中,我看到了一些针对 JQuery的标记,它包含在下面. 考虑到以下标记,ASP.NET如何确定包含JQuery所需的路径?
我使用Visual Studio 2012和内置模板(在Add – > New Project下)创建一个全新的ASP.NET Web Forms 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中注册

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读