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 gett
__doPostBack()
should be automatically included by any ASP.NET WebControl that could cause a post back. You sound like you are calling it manually in some Javascript you wrote. If so, you will need to include a WebControl, to make sure that function in inserted onto the page.
I had this problem when I wrote my own page code and forgot to put runat="server"
on the form element.
I know it's been a while since this thread was active, but I'll add another tidbit for those coming along in the future.
The ClientScriptManager class has available a couple of methods that make dealing with JavaScript postbacks better. In particular is the GetPostBackClientHyperlink routine. It retuns a string that you can then just assign to the element's onclick client-side event. Any time you use this method the __doPostBack routine and any necessary hidden form fields are automatically generated, plus you don't have to write the JavaScript yourself. For example, I have this in the Page_Load:
lnkDeactivate.Attributes("onclick") = ClientScript.GetPostbackClientHyperlink(lnkDeactivate, "deactivate")
In this case, ClientScript is the ClientScriptManager object instance automatically made available by the page...I did not instantiate it. On the post-back, I use this code to detect the event:
If Not String.IsNullOrEmpty(Request("__EVENTARGUMENT")) AndAlso Request("__EVENTARGUMENT") = "deactivate") Then
'-- do somthing
End If
I'm sure there are better/cleaner ways to hook this up, but I hope you get the idea behind it.
Try calling the RegisterRequiresPostBack method. It should make the ASP.NET runtime include the __doPostBack code.
this.Page.ClientScript.GetPostBackEventReference(<a control>, string.Empty);
This trick worked for me. Still would have liked to know why it wasn't rendering...
Thank you!
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.