views:

819

answers:

4

We got strange error last days. ___doPostBack is undefined.

We are building quite advanced website, but not using postbacks much. One of place where postback used is ASP.NET Login Status control.

It is probabalystic, sometime it is rendered, sometimes - not. For IE, Chrome it works mostly fine, but from FireFox it is quite high chance not to have doPostBack in page source.

Any ideas?

PS: In addition, error happens only on live environment, which uses Windows 2003 & IIS 5.0, dotnet framework is 3.5

Can it be because I am using OutputCache on page level? <%@ OutputCache VaryByCustom="UserLocation" VaryByParam="none" Duration="300" %>

+1  A: 

Yes it might be about the output cache, comment it out and try again please

Barbaros Alp
Page Outputcache really may lead to not rendering of doPostBack function
Sergey Osypchuk
A: 

Usually this happens when you have malformed javascript somewhere on the page (usually, before the __dopostback function).

Have you viewed the page source and looked to see if the __dopostback function is actually rendered in the page, regardless of whether you're getting the error or not?

Robert C. Barth
+3  A: 

Just happened to us: When googlebot or any other bot hits your page before a regular user, the page is cached without any postback options.

We did a simple hack, using different a outputcacheprofile if the request.browser.javascript is false (asp.net sends different versions of the page to those browsers/crawlers/bots)

djspark
If I could vote this up 10 times, I would! Just happened to us also, and so far it looks like this was the culprit. Thanks for the detailed explanation -- I'm not sure when (or if) it would have occurred to me...
Mike Powell
+1  A: 

I had the same problem, but I realized that ASP.NET does not render __doPostback when server controls don't need it.

When I put a gridview or linkbutton that need __doPostback, ASP.NET rendered it.

Diego Mendes
You are right. It seems that all controls which needs doPostBack was located within user controls with outputcache in my case.
Sergey Osypchuk