Monday, September 10, 2012

How to resolve “_doPostBack is undefined” JavaScript error in IE10?

Today I am going to share a small piece of information, most probably all of you know it, still sharing it as it caused significant amount of time killing on our development team.

The problem started when we noticed no submit button is working in ie 10 in one of our development project. further more our client identified this bug as showstopper which raised the importance level of the issue to critical for the project. Hence we decided to take a look at this issue quickly.

After few minutes of testing we didn’t noticed any problem that can cause this issue, Later we enabled “Display a notification about every Script Error” in IE 10 and then we quickly find out the issue.

image

Then immediately the problem got visible to all of us. there is what the script error looks like.

image

What is the problem?

According to Scott Hanselman

“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. Therefore, ASP.NET sees them as unknown browsers and defaults to a down-level definition, which has certain inconveniences, like that it does not support features like JavaScript. “

What is The solution?

There are two fixes for this problem

  1. Machine-wide fixes
  2. Site-only fixes

Machine-wide fixes

Please visit Hanselman blog for more information on this,

According to Mr. Hanselman

“We're releasing a hotfix that will fix these, which you'll be able to get to via some KB articles. These KBs with fixes are live and are the best way to update your system. The fixes solve the browser-detection issue forever for all sites on a machine. These will be rolled up into future versions of the framework and will eventually also be on Windows Update.

What the fixes do is update the ie.browser and firefox.browser files in \Windows\Microsoft.NET\Framework\<version>\Config\Browsers with new and future-proofed versions of these browser definitions. Nothing else is affected.”

 

Site only fixes

Go to http://nuget.org/packages/App_BrowsersUpdate, and copy the command and use nuget console to install right browser files.

The command is given bellow.

PM> Install-Package App_BrowsersUpdate

Make sure you have nuget package manager and then run the command from

image

As a Result two browser file will be added in App_Browsers folder.

image

Now if you deploy your application again you will see that every thing is working file. Cheers!

Reference

http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx

No comments:

Post a Comment