0

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.

Community
  • 1
  • 1
John Riehl
  • 1,148
  • 8
  • 19

1 Answers1

0

I have a workaround. In the debugger I can see what JavaScript is throwing the exception. So, I use Justin's code from this SO post to detect whether the client is IE...if it is, then I do the following:

(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));
        }
    }
}());

It would still be good to know why I'm getting this exception in my production code but not in the clean project, but at least now I'm working.

Community
  • 1
  • 1
John Riehl
  • 1,148
  • 8
  • 19
  • John, do you happen to have this set in your web.config? – Jeff Mergler Mar 16 '18 at 20:17
  • @JeffMergler No. Are you thinking that adding this would fix the problem, or are you thinking that having this might be causing the problem? Thanks. – John Riehl Mar 18 '18 at 16:18
  • John, the presence of the setting caused a problem in my case. When I commented it out in my web.config, the problem disappeared. I don't understand why it's interfering with my slider but I had to remove it to make the slider work in IE11. – Jeff Mergler Mar 19 '18 at 18:45
  • @JeffMergler thanks. I'm not going to sweat this since I found a workaround. – John Riehl Mar 21 '18 at 22:21
  • Fair enough. Note that I reviewed the workaround and the originating SO post and that code snippet failed for me on IE11 (it did not detect IE11, internetExplorerVersion() returned -1) so I wasn't able to detect IE and implement your workaround. Perhaps you found a reliable way to detect IE11+. – Jeff Mergler Apr 02 '18 at 21:23