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 = "";
}
}
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??
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.
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.
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
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.
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.
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’)
Rick,
You Rock…
The if statement did the trick.
Thank you for the quick and working response.
This appears to be the issue I am facing, since it causes around 40 second delay in loading page in IE8 that has an Ajax combobox, or during postback. Part of the issue is that the dropdown contains 5000+ items, however this is not an issue in compatibility mode, or in other browsers. Adding this script to the page had no noticeable effect on the perfromance. There may be more homework required in resolving this issue by Microsoft, than merely providing this function I guess.
Rick,
Where would you put the if statement
“if (typeof(Sys) !== ‘undefined’)”
I don’t have a scriptmanager on the masterpage but have it in the content pages.
You can add it in a script block in the content pages that need it.
I put the code in my .js file. my update is still taking long. Perhaps I am missing something. Should I explicitly call disposeTree at a particular place or something?
Create a StackOverflow question and post your code and I or someone else can help you.
Pingback: Ajax with Update Panel in IE = Disaster « Roby's Blog