ASP.NET UpdatePanel Javascript回调 [英] ASP.NET UpdatePanel Javascript Callback
问题描述
我最近遇到这个问题,认为这是非常有帮助的。我的问题是,在ASP.NET中通过AJAX加载更新面板后,您将如何调用一段JavaScript?
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?
我需要在面板加载后重新初始化jQuery datepicker 。
I needed to reinitialize a jQuery datepicker after the panel had loaded.
推荐答案
<script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_pageLoaded(panelLoaded);
function panelLoaded(sender, args){
// Your code here
}
</script>
本质上,这是创建一个PageRequestManager的实例,它处理所有UpdatePanel加载。然后将panelLoaded函数绑定到pageLoaded事件。
Essentially this is creating an instance of the PageRequestManager which handles all the UpdatePanel loading. Then ties the panelLoaded function to the pageLoaded event.
我也发现这篇文章解释这是更详细的: http://msdn.microsoft.com/en-us/magazine/cc163413.aspx
I also found this article which explains this is much more detail: http://msdn.microsoft.com/en-us/magazine/cc163413.aspx
这篇关于ASP.NET UpdatePanel Javascript回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!