31

I am facing a problem on IE10 with ASP.NET controls that requires JavaScript post back[like, link button].

It is properly working on the IE9 version as well as on IE10 Compatibility mode. But on the IE10 standard mode, it is giving below error. SCRIPT5009: '__doPostBack' is undefined

[I have created a demo project with a simple asp:link button that redirects to another page.] IE10_error screen

Tried the solution, but didn't work for me

Can anyone suggest fix for this?

CHANDRAHAS
  • 637
  • 3
  • 10
  • 19
  • These subjects also deserve a read, especially for the ".browser" server-side file fix ! http://stackoverflow.com/questions/18485339/dopostback-failing-in-ie-11-windows-8-1 and http://stackoverflow.com/questions/19915720/dopostback-is-undefined-in-ie11 – AFract Mar 17 '15 at 10:56

4 Answers4

50

There is apparently a bug in the browser definition files that shipped with .NET 2.0 and .NET 4. The definition files do not cater for IE10 as a browser version and hence defaults to a default definition which doesn't support JavaScript.

Scott Hanselman has a very detailed writeup about this issue here: http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx

Scott proposes two solutions, with the first one being the recommended one:

1. Machine-wide fix Download and install a hotfix on the server:

2. Site-only fix Install the App_BrowsersUpdate package from NuGet into your website to import new ie and firefox browser definitions.

Hady
  • 2,597
  • 2
  • 29
  • 34
  • Where to install the package (Site only fix) - on server side or on machine where code is compiled? – Anil Soman Nov 08 '13 at 09:08
  • The hotfix needs to be installed on the web server that serves the website - i.e. in your question's terms, the 'server side' and not the 'machine where code is compiled'. The latter is simply your development environment. – Hady Nov 10 '13 at 08:13
  • 2
    And IE11? (The hotfix does not work). Microsoft costs us SOOOOO many wasted hours. Is it time to start shunning yet another MS browser...? – Chris Jan 07 '14 at 17:35
  • Hello. About the framework update solution, just to be perfectly clear, could somebody confirm that it's only required to install the FW 4.5 (a specific version, is 4.5.1 ok ?) on hosting machine, and not to upgrade the project itself to 4.5 ? Thank you all – AFract Mar 16 '15 at 13:21
  • Would this still be occurring in VS2017 jQuery-ui, JQuery, MVC – StephanM Mar 28 '18 at 20:25
1

If you have tried the fix and you are still seeing the error in IE11, updating the .net framework to 4.5 would work.

bef
  • 11
  • 1
0

IE 10 has issues :

It can not recognize the links with _doPostBack [Which are basically seen in the HTML output of ASP Link Button]

You can refer following link for the fix :

http://ronniediaz.com/2013/02/07/ie10-imagebutton-_dopostback-undefined-bug-with-update-panel-script-manager/

Rohan
  • 1
  • 1
0

Essentially what's going on is that there are 2 missing html hidden elements "eventtarget" and "eventargument", as well as a missing function "__doPostBack".

These are missing from the DOM.

I tried all the fixes listed for this and none worked. However using a combination of jquery and javascript there is an unobtrusive solution. Add this to your javascript on document ready and you're off to the races (This is a much quicker alternative than installing the .net framework 4.5 on your server, although if you can install 4.5 thats the way to go):

if ($('#__EVENTTARGET').length <= 0 && $('#__EVENTARGUMENT').length <= 0) {
  $('#YOUR_ASPNET_FORMID').prepend('<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /><input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />');
}

if (typeof __doPostBack == 'undefined') {
  __doPostBack = function (eventTarget, eventArgument) { 
    var theForm = document.forms['YOUR_ASPNET_FORMID'];
    if (!theForm) {
      theForm = document.YOUR_ASPNET_FORMID;
    }
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
      theForm.__EVENTTARGET.value = eventTarget;
      theForm.__EVENTARGUMENT.value = eventArgument;
      theForm.submit();
    }
  };
}

I understand that some of said installing 4.5 fixes this. I would definitely recommend that. However, if you're like me working on an enterprise public facing site with a cms system baked in .net 4, this might just be an easier solution, as opposed to possibly introducing new bugs created from updating your platform.

Jon Quilliam
  • 83
  • 1
  • 5