Dec 4 2008

Why UpdateProgress Not Showing Sometimes?

Category: ASP.NET AJAXBil@l @ 22:00

I was stuck this afternoon while working on a very simple AJAX task when the UpdateProgress stopped showing for some reason when an asynchronous request is fired!

I browsed a bit online and found this nice blog post: Why the UpdateProgress won't display. I strongly recommend you read that blog post!

The UpdateProgress controls stops showing or displaying when the control that fired the asynchronous event is located outside the UpdatePanel that the UpdateProgress is attached to or when the ChildrenAsTriggers property on the UpdatePanel is set to false.

Why is this? Let us have a look at this sample code from the AJAX library:

     function Sys$UI$_UpdateProgress$_handleBeginRequest(sender, arg) {
        var curElem = arg.get_postBackElement();
        var showProgress = !this._associatedUpdatePanelId;
        while (!showProgress && curElem) {
            if (curElem.id && this._associatedUpdatePanelId === curElem.id) {
                showProgress = true;
            }

            curElem = curElem.parentNode;
        }
        if (showProgress) {
            this._timerCookie = window.setTimeout(this._startDelegate, this._displayAfter);
        }
    }

Without going into too much details look at the line bolded above! The UpdateProgress control hooks to the BeginRequest of the PageRequestManager. What happens inside this handler mainly in the bolded line shows that, only when the event is fired from inside the UpdatePanel associated to the UpdateProgress control, this controls displays its UI.

I have written articles on ASP.NET AJAX and never noticed this :). The more you learn, the more you realize there are still things missing!!!

The solution as proposed by the above link, is to hook yourself to the BeginRequest event of the PageRequestManager and display the UpdateProgress!!

 

Hope this post helped you!
Regards

 

Tags:

Comments are closed