Smit Shah

__doPostBack is not defined

I was stumped today when my ASP.Net site started creating this error

__doPostBack is not defined

I had no idea as to what was causing it.
After numerous searches and a lot of links later, I hit the target.

The reason it generated that error is simple, there are no controls on the page that are set to do a postback, so the postback function does not get sent to the client.

However, you can force the page to send the function to the client by one simple line in your page_load function


ClientScript.GetPostBackEventReference( <YOUR CONTROL NAME>, "")
In my case I have a repeater and hence
ClientScript.GetPostBackEventReference(rptPosts, "")

Hope this helps and saves you some trouble.
                                                                                         
This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet/ BOL /Other sites that are authorities in their field. Me or employer do not endorse any tools, applications, books, or concepts mentioned on the site. I have documented my personal experience on this site. The information on this site may not be up to date or accurate at times, if you are not sure or have a question, please contact me to verify information.