# Monday, 17 September 2007

The ASP.NET AJAX UpdateProgress control is rather limited.  It only shows up for UpdatePanels and then only for one at a time.  This was highly annoying, since I needed it to display for the CascadingDropDown in particular.  After a few failed attempts, I found that it is very easy to create your own control that will work for any and all requests.

The secret for this method is found in Sys.Net.WebRequestManager.  This object contains two methods:  add_invokingRequest and add_completedRequest.  Using these two events, we can set a short timeout, and using a ModalPopupExtender, show a progress alert for every background action.

var wrm = Sys.Net.WebRequestManager;

wrm.add_invokingRequest(BeginRequest);
wrm.add_completedRequest(EndReqest);

function BeginRequest(sender, args)
{
setTimeout('ShowProgress()', 800);
}

function ShowProgress()
{
// show the modal
}

function EndRequest(sender, args0
{
// hide the modal
}

I leave the rest as an exercise for the reader.

posted on Monday, 17 September 2007 16:25:15 (Central Daylight Time, UTC-05:00)  #    Comments [0] Trackback