ASP.NET __doPostBack is not defined

Wow! What a fucking morning! I came into work today to get something working. That something should have been real easy to do (you don’t need to know what it is, just that it was going to be real easy). I exported a copy of the core code, associated it to my website so that I could run the debugger through it and make my changes. This was going to form the basis of the next version of the core code.  But for some reason when I hit any button I received __doPostBack is not defined error in the javascript error console of Firebug.“Oh dear” was my first thought.  But 2 hours into trying to work it out, no luck.  EVERY website had smart arses telling me that “You need to add a .NET server control”…yeah no shit mate!  Been doing this job for long enough to know that one!

I deleted my temporary internet files, cache, cookies, .NET temporary files, everything I could think of was deleted.  I changed the port number I was using on my local machine, changed the path of my project everything in case there was something stuck somewhere.  And yes I did turn my machine on and off again!  No luck!  Now I started to get a bit annoyed!

I created a brand new page in my site – default2.aspx – added a textbox and a linkbutton.  No __doPostBack method being added!  I mean WTF!!  Then…click!  Well if this page isn’t referencing any code I wrote, no javascript, no css, nothing, then the only place that can have the error is the web.config.  Bingo!

The solution

I excluded the web.config from my project added a new one, and hey presto my default2.aspx now rendered properly with __doPostBack appearing in the HTML and the other hidden fields .NET needs! I copied all the values from my old web.config into my new version, saved it, ran the website and fuck me it worked.  So I know you have just read all that and I could have told you from the start, but I like telling stories.

So the moral of this story is, if you know it should be working, get a new web.config file.  If that doesn’t work, erm…try one of the few other solutions on the internet?  Hope this helps!

12 thoughts on “ASP.NET __doPostBack is not defined”

  1. I did have a coffee this morning 🙁 Uch oh well! Worked it out now. And got the simple bit of code I was writing done in 30mins – 2hrs to get .NET working, 30mins to rewrite the way the templates associate and work! Pants!

  2. Should’ve done a diff on the files to see what made the difference, I have a pretty much empty web.config file and having this issue 🙁

  3. I actually deleted the web.config, created a completely blank one via VS, and let the runtime update it (do you wish to alter for debug or whatever it says), and then slowly put things back. It worked for me. However I can’t guarantee this is right for you. Good luck.

  4. I just experienced the same issue, but the solution was different.
    I only had a single control added to the page and it was added using the Sitecore (CMS) with caching enabled. Disabling cache for the control fixed the problem.

    I haven’t tested if the same issue will occur if using the native output cache.

  5. This post turned out to be useful for me. I was having same issue and my web.config had following tag which caused this error

    Thanks a lot!!!!!!!!!!!!!!!

  6. IE is very weird indeed!!!!!!!!!!!!!!!!!!!! I had the same problem. After spending hours trying to figure it out, I had to rename the App_Browsers to something else and rename it back and it worked.

Leave a Reply

Your email address will not be published.