AMPEDUPDESIGNS

CONSULTING CONCEPTS PERSONAL

IE10 & ASP : _doPostBack is undefined & Exception message: Input string was not in a correct format.

May 20th, 2013

IE10 is breaking older versions of ASP.NET. In my case, a client running ASP.NET 2.0 encountered the following problems.  Here are some quick fixes for them as well.

Note:  If you notice that your problem only occurs on IE10 (and not previous versions of IE), then you might want to try this first:

Simple add this meta tag to your site header:  

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

adding this tag will tell IE10 to run in IE8 documents mode (compatibility).  This may solve your problem as a short-term fix.  Long term, IE may eventually do away with this fall-back method, so whenever possible, employ the long-term fix.

 

Now onto the problems:

1.  The "_doPostBack is undefined" error message:

Certain postback calls that asp.net creates fails for IE10.  In my case, we had a pull-down menu that would do a postback call on selection change.   This wasn't doing anything in IE10, and so taking a quick look in the console revealed this error message: "doPostBack is undefined".  Upon further investigation, its definitely more of a fix than a simple code hack.  The short story is this:  

"There is a bug in the browser definition files that shipped with .NET 2.0 and .NET 4, namely that they contain definitions for a certain range of browser versions. But the versions for some browsers (like IE 10) aren't within those ranges any more."

Hanselman explains it in his blog quite nicely here with additional solutions. 

What worked for me -- You need to run a Microsoft KB hotfix for .NET found here: 

.net 4.0 - http://support.microsoft.com/kb/2600088
.net 2.0 - http://support.microsoft.com/kb/2600100 (Win7 SP1/Windows Server 2008 R2 SP1, Windows Vista/Server 2008, Windows XP/Server 2003)
.net 2.0 - http://support.microsoft.com/kb/2608565 (Win7/Windows Server 2008 R2 RTM)

Run the hotfix on your web server, restart it and your problem should go away.

2. Exception message: Input string was not in a correct format. 

Here's another one, on a page that had an imagebutton, with IE10, the imagebutton was causing an exception.  Upon looking at the logs, I found this message: "Exception message: Input string was not in a correct format."    

So what's happening? Apparently IE10 has changed the way that it does the postback call when an imagebutton is clicked, in previous versions, IE would send back the coordinate data of the clicks in integer format,  with IE10, they decided to provide more precision by returning the coordinates in double formats instead.  The problem however is that older versions of .NET are expecting and parsing the X,Y coordinates as integers in the LoadPostData function for the ImageButton class, as such, you can see how you end up with the error message you get.

How to fix:

The proper way is to update your .NET framework to the latest version (version 4.5 seems to work). 

Now of course you may not necessarily have direct access to your server, or you're just hesitant to update your framework and possibly introduce even more problems (like me), here's another solution that worked well for me and may work for you: Force IE10 to run in a compatibility mode with your site by adding this to your header.

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

Since the site in question was designed during the end of IE6 days, I had no qualms about requesting that IE10 run in coompatibility mode, in this case, IE8.  

 

Did this help?  Let me know!