IE10 sending image button click coordinates with decimals (floating point values) causing a ParseInt32 FormatException

后端 未结 10 984
情深已故
情深已故 2020-12-08 07:48

It seems like ASP.NET 4.0 is not prepared to handle ImageButton events triggered by Internet Explorer 10. The problem is that IE10 sends the image click coordinates as doubl

相关标签:
10条回答
  • 2020-12-08 07:56

    In my case I am not currently able to upgrade .Net to 4.5 and I didn't want to use JavaScript to patch the bug.

    The solution that I went with was to convert my ImageButton to a LinkButton:

    This was my ImageButton:

    <asp:ImageButton ID="MyButton" runat="server" CausesValidation="false" ToolTip="my tooltip" ImageUrl="../Images/button.gif" OnClick="MyButton_Click" ></asp:ImageButton>
    

    This is the LinkButton I replaced it with:

    <asp:LinkButton ID="MyButton" runat="server" CausesValidation="false" OnClick="MyButton_Click">
        <asp:Image runat="server" ImageUrl="~/Images/button.gif" alt="my tooltip"/>
    </asp:LinkButton>
    

    From the user's perspective, it all works the same as it did before....but without the crashing in IE.

    0 讨论(0)
  • 2020-12-08 07:57

    Actually is a different issue than the ones listed by tkrause. There is a hotfix available, although I can't figure out how to apply it. Here is info for those that do know how to apply these:

    http://support.microsoft.com/kb/2784147

    If you check the ASP.NET section is has the exact error stated in this question. This is the exact error and issue I am having also.

    I think I cannot get the update because I'm using Server 2003. I'm using ASP.NET 3.5 and VS 2008, so upgrading to 4.x isn't an easy option for me.

    0 讨论(0)
  • 2020-12-08 08:05

    Here's a JavaScript workaround. It overrides the existing method, floors the x and y coordinates then calls the existing method with these new coordinates.

    Sys.WebForms.PageRequestManager.getInstance()._origOnFormActiveElement = Sys.WebForms.PageRequestManager.getInstance()._onFormElementActive;
    Sys.WebForms.PageRequestManager.getInstance()._onFormElementActive = function(element, offsetX, offsetY){
        if (element.tagName.toUpperCase() === 'INPUT' && element.type === 'image'){
            offsetX = Math.floor(offsetX);
            offsetY = Math.floor(offsetY);
        }
        this._origOnFormActiveElement(element, offsetX, offsetY);
    };
    
    0 讨论(0)
  • 2020-12-08 08:10

    In our case, on the master page we added below line of code under <head> section:

    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
    

    This worked for us as it allows the page to be rendered in the version of IE that is specified.

    0 讨论(0)
  • 2020-12-08 08:12

    Simply installing .NET Framework 4.5 can fix this problem.

    This can fix the problem even if you do not switch your application pool over to .NET Framework 4.5.

    In my case, I left the app pools at .NET Framework 3.5. Apparently installing .NET Framework 4.5 overwrites some files for other framework versions.

    Since it is so easy to install the new .NET Framework version, it's probably worth a try before bothering with the hotfixes (which did not work for me) or other solutions.

    See the workarounds section here

    0 讨论(0)
  • 2020-12-08 08:13

    Just put this in the header of each page or the master page:

    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    

    This will force IE10 into IE9 standards document mode, and it can handle image postbacks just fine.

    0 讨论(0)
提交回复
热议问题