__doPostBack is not defined
The run time/client side error __doPostBack
is undefined hassled me for a few hours. There was lots of misleading/incorrect help on the net. I inserted the following line of code in the Page_Load
event of the default.aspx.cs
file and everything worked fine, on my system and in production with GoDaddy.
ClientScript.GetPostBackEventReference(this, string.Empty);
If the page doesn't have a control that causes a postback, __doPostBack() won't be output as a function definition. One way to override this is to include this line in your Page_PreRender():
this.Page.ClientScript.GetPostBackEventReference(<a control>, string.Empty);
This function returns a string calling __doPostBack(); but also forces the page to output the __doPostBack() function definition.
Here's why this was happening to me: I accidentally forgot that script tags must always have closing tags:
<script src="/Scripts/appLogic/Regions.js" />
I corrected the script tag:
<script src="/Scripts/appLogic/Regions.js" type="text/javascript" ></script>
and sanity returned.