UpdatePanel Async Postsback slow in IE…Part 3


So, I have received an updated script from Microsoft for KB 2000262.  The issues I found in the last script are now fixed.  In my testing so far it appears to be faster and stable.  The JS function is below, I am sure the KB will be updated soon.

    function disposeTree(sender, args) {
        var elements = args.get_panelsUpdating();
        for (var i = elements.length - 1; i >= 0; i--) {
            var element = elements[i];
            var allnodes = element.getElementsByTagName('*'),
                length = allnodes.length;
            var nodes = new Array(length)
            for (var k = 0; k < length; k++) {
                nodes[k] = allnodes[k];
            }
            for (var j = 0, l = nodes.length; j < l; j++) {
                var node = nodes[j];
                if (node.nodeType === 1) {
                    if (node.dispose && typeof (node.dispose) === "function") {
                        node.dispose();
                    }
                    else if (node.control && typeof (node.control.dispose) === "function") {
                        node.control.dispose();
                    }

                    var behaviors = node._behaviors;
                    if (behaviors) {
                        behaviors = Array.apply(null, behaviors);
                        for (var k = behaviors.length - 1; k >= 0; k--) {
                            behaviors[k].dispose();
                        }
                    }
                }
            }
            element.innerHTML = "";
        }
    }


Part 2
Part 1

Advertisements

10 Responses to “UpdatePanel Async Postsback slow in IE…Part 3”

  1. Dominic Turner, Bristol Says:

    I tried this fix for my site – some pages had massive 40 second delays in IE after the page had rendered. This solved the problem.

    I use a master page and installed it there.

    However I now got the following error on another page:

    if (node.nodeType === 1)

    ‘nodeType’ is null or not an object ViewCommittee.aspx?ViewCommitteeID=40, line 2840 character 21

    Any idea’s??

    • rick schott Says:

      Do you have the latest function? Also, do a CTL+F5 to make sure the JS isn’t cached. What you are describing is the bug I found in the original scripts they supplied.

      • Dominic Turner, Bristol, UK Says:

        Thankyou – genius! I downloaded it yesterday from the Microsoft website and on investigation the version I had did not have the compound array “allnodes” – so I guess I somehow got the old version. The MS page now shows the same as your code above so God knows what I did.

        Thanks very much for all your help! Lifesaver! Dominic.

  2. Brad Says:

    I’m having a very similar problem, although my page uses the regular asp:Panel control instead of UpdatePanel. It takes about 30 seconds to populate the panel and load the page in IE8, and about 5 seconds or less in Firefox. What’s worse is that typing text in a text box is agonizingly slow/delayed in IE8, whereas it’s normal in Firefox on the same pc. The same goes for clicking radio buttons. I tried copying your script into the page but it’s not having an effect. I put a breakpoint on the first line but it never hits it. Any ideas? Thanks -Brad

    • rick schott Says:

      This script only works with the ScriptManager(ie: Sys namespace and async postbacks). I’d say try to put your page in an UpdatePanel so this script will be used and see what happens.

  3. David Penn Says:

    I am using a master page, so I put the script in the body. It worked great for that project. The problem is not all the projects that use the master page are Ajax enabled. On these sites I get a Sys is undefined error.
    Is there a way to check if the content page has a script manager and is so run the script else do nothing.

    • rick schott Says:

      I would probably put my ScriptManager in the MasterPage if possible, otherwise you can check with JS like this:
      You can check like this:
      if (typeof(Sys) !== ‘undefined’)

  4. David Penn Says:

    Rick,
    You Rock…
    The if statement did the trick.
    Thank you for the quick and working response.

  5. Ranjit Kumar Says:

    The description of the issue seems to match the issue I am facing. It takes around 40 seconds to load a page with update panel in IE8, and 4 seconds to load in other browsers (including IE8 in compatibility mode). The fix didn’t seem to work at all. My script manager is in master page, and update panel inside a page. I tried adding this script to master page’s head section, before end of body tag, inside the aspx page, but to no avail.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: