I am using ASP.NET to create a small web app. One of my pages includes some LinkButton controls, which used to work fine until I added a reference to Google Analytics code to it. Now, when I click on a link button, I get the error message:
Microsoft JScript runtime error: The value of the property '__doPostBack' is null or undefined, not a Function or object
The other links and controls on the page work fine. If I remove the reference to the Google Analytics script from the page, everything works fine as well. It seems that the problem arises from the interaction between the Google Analytics script and the LinkButton controls trying to postback the page.
UPDATE. I have further observed the following. When no Google Analytics script reference is present, the HTML that ASP.NET generates looks fine:
However, as soon as I add Google Analytics code, the HTML gets screwed:
Check out that form tag! I imagine now that the postback error arises from the fact that the linkbutton controls get placed outside the ASP.NET form. But why? END UPDATE.
Any ideas on how to solve this? Thanks.
FURTHER UPDATE. After much experimenting, I have been able to solve this by myself. I have added an answer below showing my conclusions. Thanks to all who have posted answers here. END UPDATE.
`)?
– keyboardP Jun 05 '11 at 17:58