【问题标题】:How to add AjaxControlToolkit to Visual Studio 2013 web-forms template?如何将 AjaxControlToolkit 添加到 Visual Studio 2013 Web 表单模板?
【发布时间】:2013-12-02 23:20:42
【问题描述】:

这已经很复杂了,我怀疑我是否可以单独处理它。现在有很多东西从一开始就包含在项目中,我不确定它们是什么以及它们是什么。

我已将 AjaxControlToolkit 添加到项目中并用于设置脚本管理器:

    <ajaxToolkit:ToolkitScriptManager runat="server"
        EnablePageMethods="true"
        EnablePartialRendering="true"
        LoadScriptsBeforeUI="true"
        AjaxFrameworkMode="Enabled">
        <Scripts>

            <asp:ScriptReference Name="jquery" />
            <asp:ScriptReference Name="bootstrap" />

            <asp:ScriptReference Name="MsAjaxBundle" />
            <asp:ScriptReference Name="respond" />
            <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" />


        </Scripts>
    </ajaxToolkit:ToolkitScriptManager>

看起来像 ajaxToolkit 形式的东西已经可以工作,但大多数情况下我在 Chrome 控制台中看到错误。

但我看到的第一个错误是:

未捕获的错误:AjaxControlToolkit 需要 ASP.NET Ajax 4.0 脚本。 确保引用了正确版本的脚本。如果你是 使用 ASP.NET ScriptManager,切换到 ToolkitScriptManager AjaxControlToolkit.dll。 ScriptResource.axd:19

我在 Scripts 文件夹中发现了很多不同的脚本,但 AjaxControlToolkit 没有提供,现在我不明白如何解决它?

【问题讨论】:

标签: c# asp.net ajax asp.net-ajax ajaxcontroltoolkit


【解决方案1】:

这可能会有所帮助: 将ajaxToolkit:ToolkitScriptManager 替换为asp:ScriptManager

这样做:

<asp:ScriptManager runat="server"
        EnablePageMethods="true"
        EnablePartialRendering="true"
        LoadScriptsBeforeUI="true"
        AjaxFrameworkMode="Enabled">
        <Scripts>

            <asp:ScriptReference Name="jquery" />
            <asp:ScriptReference Name="bootstrap" />

            <asp:ScriptReference Name="MsAjaxBundle" />
            <asp:ScriptReference Name="respond" />
            <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" />


        </Scripts>
    </asp:ScriptManager>

我解决了类似的问题。 它的作用是标签会自动注册最新的 Asp.net ajax 脚本,不会有任何错误。

如果您在母版页上声明脚本管理器,则子页应具有以下内容:

<asp:ScriptManagerProxy runat="server" />

【讨论】:

    【解决方案2】:
    猜你喜欢
    • 2014-02-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-19
    • 1970-01-01
    • 2014-01-16
    • 2023-03-17
    • 2014-03-21
    • 2015-02-12
    相关资源
    最近更新 更多