How can I run some javascript after an update panel refreshes?

asp.net, javascript, jquery, updatepanel

Solution

Adding an add_pageLoaded handler can also work.

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoadedHandler);

Note: the handler will fire for any callback, but you can use `sender._postBackSettings.panelID` to filter when you want your function called.

More samples:

- http://blog.jeromeparadis.com/2007/03/01/1501/

- http://zeemalik.wordpress.com/2007/11/27/how-to-call-client-side-javascript-function-after-an-updatepanel-asychronous-ajax-request-is-over/

Problem

I have a pageLoad function that sets some CSS on a .ascx control that I cannot change. On page load everything is fine, but when an update panel updates the control, my CSS is no longer applied. How can I rerun my function after the page updates? ``` $(function() { $("textarea").attr("cols", "30"); $("input.tbMarker").css({ "width": "100px" }).attr("cols","25"); }); ``` This obviously only runs on the initial page load. How can I run it after an update?

Original source

Related problems