views:

289

answers:

1

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.

+2  A: 
<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

a432511