Showing posts with label onclick. Show all posts
Showing posts with label onclick. Show all posts

Monday, March 26, 2012

Wait for response webservice

Hi everyone,

I'm kinda stuck over here. I hope someone can help me.

I have an input button on my page which has the onClick event and the onServerClick event. In the onClick event, the JavaScript code makes a call to a webservice. This webservice adds some records in a database table. After the webservice succesfully finishes, it response should be true.

The procedure goes like this:

function UpdateProduct(){...WebService.UpdateProduct(values, UpdateProduct_Callback);...}function UpdateProduct_Callback(response){return response;}

The onServerClick event refreshes the gridview I am using and selects the new record and its attributes.

The server side code executed by the onServerClick event should not be executed until the webservice is finished.

Is it possible to get the response in the UpdateProduct javascript function and return it? Like onClick="return UpdateProduct();"?

Thanks for your help!




No a callback is done after the WebService finishes on a seperate thread. Thats the whole point of a callBack, you dont have to wait for the method to finish executing. If you want to get the return value, wait for your method to finish, instead of using a callback.


Thanks for your quick reply.

Is there any other way to wait on the return value of the webservice through JavaScript without the callback? Or is it better do do it from the server side code?


You have to do it server side, JS only supports callbacks on webservice calls.


Thanks for your help. I will do it through server side code.

Want on click event on CollapsiblePanelExtender?

want onclick event onCollapsiblePanelExtender. how should i know that panel is cliecked or expanded.

there is a bool property for the extender called collapsed that you can use :)


but I have to do some oprations on that click like assigning datasource. also selecting items which are not this panel.


Hi shantanu,

Based on your description, Iunderstand that there are two parts to your issue. I have presented the issues and their possible solutions below:

When a click event is fired , you want whether the CollapsiblePanelExtender is collapsed or not.


Excellent example, this cleared things out for me at least...
Thanks!

/Mats


I know this thread already has an answer but I found another solution that suited me better and wanted to share it. The event will be triggered after the animation is complete.

<script type="text/javascript" language="javascript"> var objExtender; // this will run automatically when the page has finished loading function pageLoad(sender, args) { objExtender = $find("<%=CollapsiblePanelExtenderObject.ClientID%>"); objExtender.add_expandComplete(getCollapsibleState); objExtender.add_collapseComplete(getCollapsibleState); } function getCollapsibleState() { if(objExtender.get_Collapsed()) { // code for when it is closed } else { // code for when it is opened } } </script>

Hi Mastl,

I have been very impressed with your high level of technical proficiency; it has been a pleasure working with you. Big Smile

Best Regards,

Jonathan


Thanks, the same to you!

This forum really is fantastic. Great to be able to get help from people like you, who really knows their stuff.

Best regards,
Mats