Sunday, March 11, 2012

need to check if any async call is been raised when using PageMethods?

I believe you can use the PageRequestManager for that. It has a property calledIsInAsyncPostBack.


that partially worked but only for the update panel events. My custom PageMethod could not detect if another page Method was called.


Hi,

If the page method conflicts with UpdatePanel, michielvoo's idea should work.

If two page method conflict, you can add a global variable(client side) in the page, and use it as an lock.

For instance

var lock = false;

function myFunction()

{

if(!lock)

{

lock = true;

pageMethods.invoke(onComplete);

}

else

{

window.setTimeout(myFunction, 30000);

}

}

function onComplete(result)

{

// handle result here

lock = false;

}

Hope this helps.


right, i was thinking of doing in that way but i was kinda looking for more generic way- something that can check both UpdatePanel and PageMethod.


As far as I know, there is no generic way unless extending the client library.


I'm using similar technic as Raymond suggest, but I've allways use the error handling callback functions also.

Because: If one of the method failed it is possible that the lock variable remains true forever? What do you think Raymond?

Thank you.


Yes, you are right and your idea is always a good practice.

No comments:

Post a Comment