如何将AjaxControlToolkit添加到Visual Studio 2013 Web Forms模板?

4

这已经变得非常复杂了,我怀疑自己能否独立处理。从一开始就有很多事情涉及到项目中,我不确定它们是做什么的。

我已经将AjaxControlToolkit添加到项目中,并使用类似设置Script Manager的方式:

    <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,请切换到AjaxControlToolkit.dll中的ToolkitScriptManager。 ScriptResource.axd:19

我在Scripts文件夹中找到了许多不同的脚本,没有提供与AjaxControlToolkit一起使用的脚本,现在我不知道如何解决这个问题?


看看这个是否有帮助:http://timscyclingblog.wordpress.com/2013/03/22/ajaxcontroltoolkit-version-7-0123-with-net-4-5/,以及这个:http://blog.thinkoriginally.com/2010/05/03/microsoft-jscript-runtime-error-ajaxcontroltoolkit-requires-asp-net-ajax-4-0-scripts/。 - Zaki
@Sam 谢谢,这个链接 http://timscyclingblog.wordpress.com/2013/03/22/ajaxcontroltoolkit-version-7-0123-with-net-4-5/ 真的很有帮助。你能把它设为答案吗? - cnd
2个回答


0
这可能会有所帮助: 将 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" />

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接