Take the 2-minute tour ×

Is it OK to use __doPostBack() or it is not recommended because it is generated from ASP.Net and we are not sure if they changed it in a next version of ASP.Net.

share|improve this question
add comment

4 Answers

up vote 11 down vote accepted

I would advice against it, since it's internal stuff of ASP.NET and was never meant to be used directly.

Instead, what I'm doing when I need to "manually" trigger PostBack is adding hidden "server side" button with the proper OnClick:

<asp:Button id="btnDummy" runat="server" OnClick="Foo" style="display: none;" />

Then the JS is:


This way I don't care how post back happens, I just trigger the natural flow of events.

share|improve this answer
add comment

You should not call it directly. You should generate the javascript call by using functions in Page.ClientScript such as:

This will ensure that it's always compatible.

share|improve this answer
add comment

They probably won't change it, but why call it directly?
I think it's a better strategy to trigger the event (a button click for example) and let the control trigger the postback.

I you do need to trigger the postback directly it's recommended to use the Page.ClientScript functions tenfour described.

share|improve this answer
add comment

I think its perfectly fine to use directly, and have used it without fail, its just a javascript function after all.

share|improve this answer
Yes, it's "just a javascript function", but the problem is that there is no guarantee that it will be present in a next version. –  Hans Kesting Mar 27 '11 at 12:24
add comment

Your Answer


