本文介绍了如何在更新面板刷新后执行 javascript(无法获取 Sys.WebForms.PageRequestManager.getInstance().add_endRequest(); 以工作)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在更新面板刷新后运行 javascript.我已经阅读了一些您可以使用与此类似的代码的地方:
I'm trying to run javascript once an update panel has refreshed. I've read a few places that you can use code similar to this:
function codeToRun() {
//Code Here
}
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(codeToRun);
但它似乎不起作用……有什么想法吗?我已经尝试将代码放在更新面板的内容区域内以及它的外部......到目前为止还没有任何运气.如果您对为什么会发生这种情况有任何见解,请告诉我.
But it doesn't seem to be working... any ideas? I've tried putting the code inside the Content area of the update panel as well as outside of it... haven't had any luck so far. Please let me know if you have any insight to why this might be happening.
谢谢,
马特
推荐答案
一切都需要在 UpdatePanel 之外:
Everything needs to be outside of the UpdatePanel:
标记:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
脚本:
if( typeof(Sys) != "undefined" )
{
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(initRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
}
else
{
//we have a problem with ScriptManager
}
这篇关于如何在更新面板刷新后执行 javascript(无法获取 Sys.WebForms.PageRequestManager.getInstance().add_endRequest(); 以工作)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!