Wednesday, September 17, 2008

Disable Submit Button on AJAX Updatepanel Request

Alright so there is a bunch of stuff out there on the topic.  A good 4 hours of work had been waisted looking for the solution, and because of all the blogs i was chasing my own tail per say.

So here is my solution for disabling a submit button on an AJAX request using an update panel.

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequestHandler);
prm.add_endRequest(EndRequestHandler);        

function InitializeRequestHandler(sender, args) 
{
     document.getElementById('<% Response.Write(submitButton.ClientID); %>').disabled = true;
}       

function EndRequestHandler(sender, args) 
{
document.getElementById('<% Response.Write(submitButton.ClientID); %>').disabled= false;    
So i think this is a nice elegent solution.  Uses javascript events being fired off by the Updatepanel.

No comments: