更新面板刷新后如何运行一些 javascript? [英] How can I run some javascript after an update panel refreshes?
问题描述
我有一个 pageLoad 函数,它在我无法更改的 .ascx 控件上设置一些 CSS.在页面加载时一切正常,但是当更新面板更新控件时,我的 CSS 不再适用.页面更新后如何重新运行我的函数?
I have a pageLoad function that sets some CSS on a .ascx control that I cannot change. On page load everything is fine, but when an update panel updates the control, my CSS is no longer applied. How can I rerun my function after the page updates?
$(function() {
$("textarea").attr("cols", "30");
$("input.tbMarker").css({ "width": "100px" }).attr("cols","25");
});
这显然只在初始页面加载时运行.更新后如何运行它?
This obviously only runs on the initial page load. How can I run it after an update?
推荐答案
添加 add_pageLoaded 处理程序也可以.
Adding an add_pageLoaded handler can also work.
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoadedHandler);
注意:处理程序会为任何回调触发,但您可以使用 sender._postBackSettings.panelID
来过滤何时需要调用您的函数.
Note: the handler will fire for any callback, but you can use sender._postBackSettings.panelID
to filter when you want your function called.
更多示例:
- http://blog.jeromeparadis.com/2007/03/01/1501/
- http://zeemalik.wordpress.com/2007/11/27/how-to-call-client-side-javascript-function-after-an-updatepanel-asychronous-ajax-request-is-over/
这篇关于更新面板刷新后如何运行一些 javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!