Learning While Aging

Input string was not in a correct format error when clicking ImageButton in IE 10 or higher

First of all, this is not a new issue.

If you have an old .NET web form, especially prior to .NET 4.5, with an ImageButtonĀ in a UpdatePanel, then when you click on the ImageButton in IE 10 or higher browser, then you will encounter an error:

The input string was not in a correct format

Without going into the details of the root cause, I will just list the fixes here:

Fix 1:

Simply upgrade to .NET framework 4.5. This will take care of the error.

Fix 2:

If the fix 1 is not an option for you, i.e. your web server cannot install .NET framework 4.5, then you can try adding this line of code in the HTML header section of the page that causes the error:

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

This will force the .NET framework to render the web form into IE 9 mode which will not cause the aforementioned error. If you have several web forms that cause the error, then you can the following section in your system.webServer node in your web.config file to force the entire application to run in IE 9 mode:

<httpProtocol>
<customHeaders>
<clear />
<add name=”X-UA-Compatible” value=”IE=9″ />
</customHeaders>
</httpProtocol>