ASP.NET - UpdatePanel 和 JavaScript [英] ASP.NET - UpdatePanel and JavaScript
问题描述
有没有办法在 UpdatePanel 进程完成后执行脚本.
Is there a way to execute script when an UpdatePanel process is finished.
我有一个允许插入"、复制"和编辑"记录的页面.这一切都是在 UpdatePanel 上完成的,以防止页面导航.在页面上的其他地方,我想打印一条闪现"消息 - 例如您已成功输入记录".它不在 UpdatePanel 附近,我想对消息使用 jQuery 效果,以便它在 4 秒后淡出.如何将脚本与 UpdatePanel 一起发送回或在 UpdatePanel 刷新后执行?我应该将脚本写入 asp:literal 吗?想法?
I have a page that allows "inserting", "copying", and "editing" of a record. This is all done on an UpdatePanel to prevent a page navigation. Somewhere else on the page I would like to print a "flash" message - like "You have successfully entered a record." It is not near the UpdatePanel and I'd like to use a jQuery effect on the message so it fades out after 4 seconds. How can I send script back with the UpdatePanel or have it execute after a UpdatePanel refresh? Should I write script to an asp:literal? thoughts?
推荐答案
是:
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
然后:
function endRequestHandler(sender, args)
{
// Do stuff
}
文档此处和此处.请记住,这将针对页面上的每个 AJAX 请求触发.
Documentation here and here. Keep in mind that this will fire for every AJAX request on the page.
这篇关于ASP.NET - UpdatePanel 和 JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!