本文介绍了我如何prevent用户点击两次按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有了这个过程需要30秒左右的一个按钮被点击时运行旧的ASP.NET Web窗体应用程序(.NET 2.0)。我需要prevent按钮被点击了两次。这将prevent张贴两次,这会导致在数据库中重复的数据

I have an old ASP.NET web forms application (.NET 2.0) that has a process that takes 30 seconds or so to run when a button is clicked. I need to prevent the button from being clicked twice. This will prevent posting twice, which causes duplicate data in a database.

我尝试添加;

OnClientClick="this.disabled='true';"

尝试在JavaScript中禁用按钮。然而,尽管该按钮被禁用,按钮的回传则不起作用。

to try to disable the button in JavaScript. However, though the button becomes disabled, the postback for the button then doesn't work.

禁用按钮prevent一稿多投是适合这种应用。我怎样才能做到这一点?

Disabling the button to prevent multiple submissions is the ideal for this application. How can I do this?

我无法使用第三方控件。

I am unable to use third-party controls.

推荐答案

您必须在以后的OnClientClick返回true:

You must return true after the OnClientClick:

OnClientClick="this.disabled='true';return true;"

如果回发是继续

在客户端的任何点击必须返回true,这是按钮presses提供客户端validatin的手段。

Any clicks in client-side must return true if the postback is to continue, it's a means of providing client-side validatin on button presses.

这篇关于我如何prevent用户点击两次按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 05:21
查看更多