部分回发C#后JS插件无法正常工作 [英] JS plugin not working after partial post back C#

查看:107
本文介绍了部分回发C#后JS插件无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net中使用主页和内容页面。如果需要,我在特定的asp内容页面中加载特定的插件JS文件。我在页面初始加载插件工作正常时更新了一些数据,但是当页面部分回发时,插件无效,因为当时JS文件未加载,因此插件不适用于每个asp控件。

请帮帮我!

谢谢。



我尝试过的事情: < br $>


i已经在updatepenal中加载了JS fiel并且只是在每个部分帖子上更新了updatepenel但是它没有用。

I am using master and content page in asp.net. i load specific plugin JS file in a specific asp content page if required. i have update some data in update penal when page initial loads the plugins are working fine but when page is partially post back the plugin not working because at the time the JS files not loaded so the plugin not apply on each asp controls .
Please can you help me!
Thanks.

What I have tried:

i have load the JS fiel in updatepenal and just update the updatepenel on every partial post back but it's not working.

推荐答案

这很可能是因为您在加载页面时将事件附加到元素,但updatepanel正在删除这些元素并将其替换为新元素,因此您的事件附加到的所有元素现在都消失了。有不同的处理方法,例如在jQuery中使用委托事件,或使用updatepanel公开的事件来绑定事件而不是使用document.ready。由于您尚未发布任何相关代码,我们无法提供具体帮助,但正如上面建议的那样google,因为这是一个记录良好的问题。



< a href =https://forums.asp.net/t/1982846.aspx?How+to+run+javascript+after+updatepanel+execution+completed>如何在updatepanel执行完成后运行javascript ASP.NET论坛 [ ^ ]
This is most likely because you attach events to the elements when the page is loaded, but the updatepanel is deleting those elements and replacing them with new ones so all of the elements your events were attached to are now gone. There are different ways of handling this such as using delegate events in jQuery, or using an event exposed by the updatepanel to bind your events rather than using document.ready. As you haven't posted any relevant code we can't give specific help, but as suggested above google for it as it is a well-documented problem.

How to run javascript after updatepanel execution completed | The ASP.NET Forums[^]


这篇关于部分回发C#后JS插件无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆