单击后禁用asp.net按钮以防止双击 [英] Disable asp.net button after click to prevent double clicking

查看:30
本文介绍了单击后禁用asp.net按钮以防止双击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ASP.NET 按钮,我需要在用户单击它后将其禁用以防止双击.提交完成后,必须再次启用它.有人能帮我解决这个问题吗?

I have an ASP.NET button that I need to disable after the user clicks it to prevent double-clicking. Once the submit completes it has to be enabled again. Can anyone help me with this?

推荐答案

这是一个适用于 asp.net 按钮对象的解决方案.在前端,将这些属性添加到您的 asp:Button 定义中:

Here is a solution that works for the asp.net button object. On the front end, add these attributes to your asp:Button definition:

<asp:Button ... OnClientClick="this.disabled=true;" UseSubmitBehavior="false" />

在后端,在点击事件处理程序方法调用中,将此代码添加到最后(最好在finally块中)

In the back end, in the click event handler method call, add this code to the end (preferably in a finally block)

myButton.Enabled = true;

这篇关于单击后禁用asp.net按钮以防止双击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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