Thursday, June 6, 2013

ImageButton (asp.net) failed to work in IE10

When you are running your asp.net website (.net 3.5) in IE10 with some ImageButton-s together with the ScriptManager, you might have a chance in triggering the following error:

Sys.WebForms.PageRequestManagerServerErrorException input string was not in a correct format

To resolve this, you need to add the following script after the end of the "Form" HTML tag.

<script type="text/javascript">
    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);
    };
</script>

For more details, please read the following URL:

http://stackoverflow.com/questions/13299685/ie10-sending-image-button-click-coordinates-with-decimals-floating-point-values

5 comments: