Fix: UpdatePanel Async Postbacks Slow in Internet Explorer

Article translations Article translations
Article ID: 2000262 - View products that this article applies to.
Expand all | Collapse all

Symptoms

When using Internet Explorer to browse a page that contains an UpdatePanel, there is a delay (often anywhere between 10 seconds and 45 seconds or more) after clicking a page element that initiates an async postback. The delay is not experienced when using browsers other than Internet Explorer.

Cause

The PageRequestManager's _destroyTree method iterates through the DOM elements inside of the UpdatePanel prior to initiating an async postback in order to dispose of DOM elements. The _destroyTree method's specific implementation is very slow in Internet Explorer when working with a large DOM tree under some conditions due to the way that Internet Explorer's HTML viewer (mshtml.dll) stores DOM elements in memory.

Resolution

Add the JavaScript below immediately before the closing </body> element of the page experiencing the delay.

<script language="javascript" type="text/javascript">

      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 = "";
        }
    }


Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(disposeTree);

</script>

 

More Information

This script uses the getElementsByTagName method which is much faster in Internet Explorer than the original implementation.

This problem will be corrected in the next version of ASP.NET.

Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

Properties

Article ID: 2000262 - Last Review: September 11, 2009 - Revision: 7.0
APPLIES TO
  • Microsoft ASP.NET 3.5
Keywords: 
KB2000262

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com