如何防止更新面板中的按钮被点击两次?

发布于 2024-08-25 16:37:12 字数 50 浏览 3 评论 0原文

我在更新面板中有一个按钮。当我单击按钮时,它单击事件运行两次。如何防止第二次点击事件?

I have a button which is in update panel. When I click on button then it click event run two times. How can I prevent second time click event?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

薯片软お妹 2024-09-01 16:37:12

我也有同样的问题。

我在 aspx 代码中有一个“onclick=swap_img”,在 vb 代码中有以下内容,因此它运行了两次。我刚刚删除了 aspx 代码中的 onclick:

Protected Sub swap_img(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles btn_img.Click

这篇文章帮助我解决了这个问题: http:// forums.asp.net/t/1056418.aspx

I had the same problem.

I had an "onclick=swap_img" in the aspx code and the following in the vb code so it ran twice. I just removed the onclick in the aspx code:

Protected Sub swap_img(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles btn_img.Click

This article helped me figure this problem out: http://forums.asp.net/t/1056418.aspx

空宴 2024-09-01 16:37:12

检查您是否未将处理函数两次附加到单击事件(例如,一次通过 html/javascript 一次,一次在 vb 代码中)。

Check if you did not attach the handler function twice to the click event (for example once by html/javascript and once in the vb code).

穿透光 2024-09-01 16:37:12

为什么不在按钮回调函数开始时禁用按钮...

然后,使用诸如 try/finally 块之类的合理内容,在最后的finally 中启用按钮。

Why not disable the button at the start of the button callback function...

Then, using something sensible like a try/finally block, enable the button at the end, in the finally.

痴情换悲伤 2024-09-01 16:37:12

在页面加载时,您可以使用:

button.Attributes.Add("onClick", "<< javascript >>")

... 将一些 javascript 附加到按钮的 Click 事件。

您可以通过简单的 Google 搜索找到用于禁用该按钮的 javascript。

On Page load, you can use:

button.Attributes.Add("onClick", "<< javascript >>")

... to attach some javascript to the Click event of the button.

You can find javascript to disable the button with a simple Google search.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文