Sunday, March 11, 2012

UpdatePanel breaking javascript after update

Hi,

if you are referencing, with JavaScript, elements that are contained inside an UpdatePanel, those references will become invalid after an update, because the updated HTML replaces the old one and the DOM tree is changed.

A solution could be to restore the references by putting the initialization code in a separate function and calling it whenever the panel has finished to update.


Thanks for the reply. I am not making any references to the UpdatePanel from the Javascript, but I am going to try reinitializing the script anyway. It's possible that the changes to the DOM could be messing things up in an unexpected way.

Using information from here: http://forums.asp.net/thread/1416330.aspx#1417136

I hooked _PageRequestManager to run an initialization function that was buried in one of the many javascript snippets we use in our custom framework, and that fixed things right up.

Thanks for the pointer. That's what got me going in the right direction.

Colin

No comments:

Post a Comment