简体   繁体   English

在更新面板 AJAX asp.net 之后运行脚本

[英]Running script after Update panel AJAX asp.net

I am running an ajax update panel in my website.我在我的网站上运行 ajax 更新面板。 The update panel returns some new controls.更新面板返回一些新控件。 I would like to set some JavaScript for the controls after they are returned from the ajax call.我想在从 ajax 调用返回后为控件设置一些 JavaScript。 Is there any way of doing this?有没有办法做到这一点? Thanks for any help!谢谢你的帮助!

tie into the MSAjax Event与 MSAjax 事件相关联

function pageLoad(){ } 

this will fire every time the update panel refreshes.. you can do your rebinding / new bindings there每次更新面板刷新时都会触发..您可以在那里进行重新绑定/新绑定

...and yes, that's all you need to do, put that on the page and it will fire. ...是的,这就是你需要做的,把它放在页面上,它就会启动。

Update:: [looks like i had the function named incorrectly ( i think it would still work tho) ] it's really that simple if you have a script manager on the page ..更新:: [看起来我的函数命名不正确(我认为它仍然可以工作)]如果页面上有脚本管理器,那真的很简单..

<script> 
   ///<summary>
   ///  This will fire on initial page load, 
   ///  and all subsequent partial page updates made 
   ///  by any update panel on the page
   ///</summary>
   function pageLoad(){ alert('page loaded!') }  
</script>

http://www.asp.net/ajax/documentation/live/overview/AJAXClientEvents.aspx http://www.asp.net/ajax/documentation/live/overview/AJAXClientEvents.aspx

Archived:存档:

https://web.archive.org/web/20160802132945/http://ajax.asp.net/ajax/documentation/live/overview/AJAXClientEvents.aspx https://web.archive.org/web/20160802132945/http://ajax.asp.net/ajax/documentation/live/overview/AJAXClientEvents.aspx

You could use a Timer with a function that checks if the controls exists every few hundred ms.您可以将 Timer 与一个函数一起使用,该函数每隔几百毫秒检查一次控件是否存在。 Once it detects them, apply your script and end the timer.一旦检测到它们,应用您的脚本并结束计时器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM