Ajaxcontroltoolkit 15.1.2 Tabcontainer problems

自闭症网瘾萝莉.ら 提交于 2019-12-25 13:16:07

问题


I've just upgraded a legacy web application from .NET 3.5 to .NET 4.5. The application extensively used the AjaxControlToolkit. Since a new version is available from May 2015, I also upgrade it.

I received several errors so I tried to create an empty project from scratch, adding the AjaxControlToolkit through Nuget, and it seems the problem is caused by the TabContainer control.

I receive the errors shown in the images below:

SCRIPT1028: Expected identifier, string or number

0x800a139e - JavaScript runtime error: Sys.ArgumentUndefinedException: Value cannot be undefined.

Obviously after those error there's no TabContainer in the page.

The strange thing is that it happens just in Internet Explorer 9+. It works like a charm in Firefox and Chrome.

The application is nearly empty, here's the relevant code from the page:

<asp:ScriptManager ID="sm" runat="server">
</asp:ScriptManager>
<ajaxToolkit:TabContainer ID="tc" runat="server">
    <ajaxToolkit:TabPanel ID="tp1" runat="server">
        <HeaderTemplate>
            Header
        </HeaderTemplate>
        <ContentTemplate>
            Content
        </ContentTemplate>
    </ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>

Any ideas?


回答1:


It seems that you have to use Bundling to get it work.

In the project mentioned in the question I have added the AjaxControlToolkit 15.1.2 reference using nuget.

To solve the problem I have enabled bundling as explained on CodePlex:

  1. Add the reference to AjaxControlToolkit.StaticResources using nuget
  2. Change the ScriptManager to the following:

    <asp:ScriptManager runat="server">
        <Scripts>
            <asp:ScriptReference Path="~/Scripts/AjaxControlToolkit/Bundle" />
        </Scripts>
    </asp:ScriptManager>
    
  3. Add the following to the <head> element:

    <asp:PlaceHolder runat="server">
        <%: System.Web.Optimization.Styles.Render("~/Content/AjaxControlToolkit/Styles/Bundle") %>
    </asp:PlaceHolder>
    
  4. Be sure you have this in the web.config:

    <ajaxControlToolkit useStaticResources="true" renderStyleLinks="false" />
    


来源:https://stackoverflow.com/questions/31348100/ajaxcontroltoolkit-15-1-2-tabcontainer-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!