ASP.NET UpdatePanel Javascript Callback

I came across this issue recently and thought it was really helpful. My question was, how would you call a piece of javascript after an updatepanel loads via AJAX in ASP.NET?

I needed to reinitialize a jQuery datepicker after the panel had loaded.

Answers


<script type=”text/javascript”>

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_pageLoaded(panelLoaded);

function panelLoaded(sender, args){

    // Your code here

}

</script>

Essentially this is creating an instance of the PageRequestManager which handles all the UpdatePanel loading. Then ties the panelLoaded function to the pageLoaded event.

I also found this article which explains this is much more detail: http://msdn.microsoft.com/en-us/magazine/cc163413.aspx


Need Your Help

How to get over limitations of the Hibernate Criteria and Example APIs?

java hibernate upgrade hibernate-criteria

I'm in a position where our company has a database search service that is highly configurable, for which it's very useful to configure queries in a programmatic fashion. The Criteria API is powerfu...

(Windows 8 Javascript) WinJS.xhr does not reflect changes from api

javascript visual-studio-2012 windows-8 winjs

I am developing an app, where I access photos from an slr via a wifi-sd-card. Right now, I am trying to retrieve the html response from a particular location on the camera and retrieve all the imag...