Initiate PostBack From Client-side Script

J

Jordan

I'm trying to initiate Postback from client-side script, and here's what I
have that doesn't work: I have an <asp:Button> on the same page named
btnSave that the user can click (its functionality works fine). I want to
call the button's server-side functionality from the client-side script (in
response to things happening in the client other than the user clicking on
the save button).

function DoSomethingInClient()
{
Do Some Stuff Here
__doPostBack('btnSaveClick','');
}

What could be wrong with this?

Thanks.
 
D

Dale

Are you sure you have the method __doPostBack() in your client? If you
don't have any controls set for postback, it can happen that the code is not
generated to the client.

In the Framework documentation or MSDN, search for the article titled
"Generating Client-Side Script for Postback."

It talks about the GetPostBackEventReference method. This method will
return method call string so you can use it in programatically generated
client scripts but the most important thing it will do for you is that, if
it doesn't already exist by other means, it will generate the __doPostBack
method itself so that you can call it.

Dale Preston
MCAD, MCSE, MCDBA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top