Saturday, March 24, 2012

want to disable button for the webmethod running time

Hi,

Iam using time-consuming webmethod and on the client page atlas:timecontrol for automatic refresh part of page. I want to disable button(whitch start the 5hours webmethod). The one way to disabling is using method in form tag:

onsubmit="DisableButtons()"
But this event is calling every (for example) 5 seconds of automatic refreshing of atlas:timecontrol.
Exist the way to disable button after click the start button and after ending this method button enable back? 
Thanks a lot. 

Hello,

The way to accomplish this is something like the following:

function onServiceComplete(result) {
var button = $get('myButtonElementId');
if (button) {
button.style.disabled = ''; // enable
}

// do stuff with result here...
}

function callService(stuff) {
var button = $get('myButtonElementId');
if (button) {
button.style.disabled = 'disabled'; // disable
}

var serviceParam = stuff;
MyServiceName.DoStuff(serviceParam, onServiceComplete, function(serviceErr) {
// be sure to re-enable when error occurs...
button.style.disabled = '';
var errorDiv = $get('myErrorDiv');
errorDiv.innerText = serviceErr.get_message();
});
}

I hope this helps.

No comments:

Post a Comment