Im getting that error when try to call a __doPostBack on one of my pages, every page that i have in the project use __doPostBack function but in this particular page im getting that Javascript error.
i was looking in the internet and the only thing i read is that this error happends when i have a unclose tag but i review the site and its ok.
Error: __doPostBack is not defined Source File: htt://localhost:99/ProjectName/Disable.aspx Line: 1
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.
Just add this code to your .aspx
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With