AjaxToolkit SliderExtender generates JavaScript exceptions in IE11

时间:2016-04-21 22:15:10

标签: asp.net ajaxcontroltoolkit

I'm using an ajaxToolkit:SliderExtender in an UpdatePanel like so:

<asp:UpdatePanel ID="upSlideshow" runat="server">
    <ContentTemplate>
        <asp:TextBox ID="txtSlideBackgroundOpacity" runat="server"
            ReadOnly="true"
            ToolTip="Adjust the opacity of the background (0 is fully transparent, 100 is fully opaque)"
            OnTextChanged="txtSlideBackgroundOpacity_TextChanged"
            AutoPostBack="true" />
        <br />
        <asp:TextBox ID="txtOpacitySlider" runat="server" />
        <ajaxToolkit:SliderExtender ID="seSlideBackgroundOpacity" runat="server"
            TargetControlID="txtOpacitySlider"
            BoundControlID="txtSlideBackgroundOpacity" />
    </ContentTemplate>
</asp:UpdatePanel>

Works fine in Edge, Firefox, and Chrome, but generates the following exception in IE11:

0x800a139e - JavaScript runtime error: Sys.ArgumentOutOfRangeException: Value must be an integer.

From this post I looked at compatibility settings, and from this post I've tried various combinations of the <meta http-equiv="X-UA-Compatible" content="..." /> tag...anything below IE=11 breaks other things in the site and IE=11 and IE=edge both give me the exception.

I created a clean ASP.NET WebForms project to see if I could isolate the problem, but the slider works in that project, so there's likely some setting in my project that's causing the problem. Any ideas where I should start looking? Thanks.

1 个答案:

答案 0 :(得分:0)

我有一个解决方法。在调试器中,我可以看到JavaScript抛出异常。所以,我使用来自this SO post的Justin代码来检测客户端是否是IE ...如果是,那么我会执行以下操作:

(function () {
    // if we're running internet explorer, we need to fix one of the internal routines to allow for the SliderExtender control to work
    var nIEVersion = internetExplorerVersion();

    if (nIEVersion && nIEVersion <= 11) {
        var originalSetLocation = Sys.UI.DomElement.setLocation;

        Sys.UI.DomElement.setLocation = function (element, x, y) {
            originalSetLocation(element, Math.floor(x), Math.floor(y));
        }
    }
}());

知道为什么我在我的生产代码中得到这个例外而不是在干净的项目中,这仍然是一件好事,但至少现在我正在工作。