asp.net 更新面板之外的 jQuery
我有一个正在使用和更新面板的 asp.net 页面,并且通过 {script src=abc.js} 标记包含一些 javascript。我尝试使用 $(document).ready 和 $(window).load 加载我的 javascript。两者都在初始加载时触发,但在更新面板回发时无法触发。
有什么我可以连接客户端的东西,无论更新面板如何,都会触发?我知道我可以在服务器端注入脚本,但理想情况下我希望在所有客户端都执行此操作,并在第一次时连接所需的内容。
I have an asp.net page that is using and update panel and am including some javascript via a {script src=abc.js} tag. I have tried loading my javascript using both $(document).ready and $(window).load. Both fire on the initial load but fail to fire on an update panel postback.
Is there anything I can wire up client side that would fire regardless of the update panel? I know I can inject script server side but I ideally want to do this all client side and wire up what ever is needed the first time around.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您希望注册一些代码以便即使在
UpdatePanel
回发时也始终运行,则需要注册要在更新发生时调用的函数。您可以通过执行以下操作来注册要运行的 javascript 函数:当 UpdatePanel 刷新时,
PageRequestManager
将调用您的 javascript 函数。过去,当
UpdatePanel
由于计时器触发刷新时,我曾使用此方法触发触发器。刷新完成后,脚本将自动运行以根据显示的数据更新其他控件。有关详细信息,请参阅这篇 MSDN 文章。
If you want to register some code to always run even on an
UpdatePanel
postback, you will need to register your function to be called when an update occurs. You can register a javascript function to run by doing the following:The
PageRequestManager
will call your javascript function when the UpdatePanel refreshes.I have used this in the past to cause a trigger when an
UpdatePanel
fired a refresh due to a timer. When the refresh completed, the scripts would automatically run to update other controls based on the data that was displayed.See this MSDN article for more information.
将这些行嵌入您的 javascript 标签
然后,将其放在您的 body 标签上
Embed these lines on your javascript tag
Then, put this on you body tag