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:

Nov 16 2008

ASP.NET AJAX's CompositeScript in .NET 3.5 SP 1

Category: .NET 3.5 SP1 | ASP.NET AJAXBil@l @ 09:28

The .NET 3,5 SP1 adds several features to the .NET products. One of the major improvements in my opinion regarding the ASP.NET AJAX 3.5 is the CompositeScript.

Usually, when you place a ScriptManager instance on the page, you include several scripts and you place them within the Scripts class collection. This means, if you had like 5 scripts to load, you will have 5 different calls to the server to request the 5 script files.

The improvement in .NET 3.5 SP1 is the addition of the CompositeScript class that allows you to group a collection of script files and have them rendered to the cllient as a single script file and hence instead of requesting 5 script files (according to the example above), you will be requesting a single script and hence minimized the requests to server from 5 to 1.

<asp:ScriptManager ID="ScriptManager1" runat="server">
<CompositeScript>
<Scripts>
<asp:ScriptReference Path="~/Scripts/Script1.js" />
<asp:ScriptReference Path="~/Scripts/Script3.js" />
</Scripts>
</CompositeScript>
</asp:ScriptManager>

 As you can see this has a great improvement in performance since less requests will be issued to the server.

 

Regards

 

Tags: ,