简体   繁体   English

如何使按钮只能单击一次

[英]How to make a button only clickable once

I AM Microsoft Visual Studio Basically I'm learning ASP and I'm trying to make an OnButtonClick postback. 我是Microsoft Visual Studio,基本上我正在学习ASP,并且正在尝试进行OnButtonClick回发。 But when ever I try to make it OnButtonClick = true; 但是,无论何时我尝试使其变为OnButtonClick = true; Return SendButton.visible = false 返回SendButton.visible = false

I need to make my SendButton_Click So that when someone clicks * send * the button becomes unclickable. 我需要设置我的SendButton_Click,以便当某人单击*发送*时该按钮变为不可单击。

I've tried searching the web, Our IT Guy said to google it but I just can't find what I need. 我尝试搜索网络,我们的IT专家对Google说,但是我找不到我需要的东西。

If someone can help. 如果有人可以帮助。

I've attempted to use the following code, With no Succession. 我尝试使用下面的代码,不进行继承。

<script type="text/javascript">
var wasSubmitted = false;
function checkBeforeSubmit() {
    if (!wasSubmitted) {
        wasSubmitted = true;
        return wasSubmitted;
    }
    return false;
}
</script>
<form onsubmit="return checkBeforeSubmit()" /> 
<asp:Button ID="SendButton" runat="server" Text="Send" OnClick="SendButton_Click OnClientClick="Disable" />    

I want to make it so after the person has CLICKED: Send - They cannot click it multiple times there for sending the request multiple times. 我想在此人点击后发送:发送-他们无法多次单击该请求以多次发送请求。

As you're using WebForms have a look at PostBack Ritalin - it will do what you require very easily. 当您使用WebForms时,请查看PostBack Ritalin-它可以轻松满足您的要求。

Or: 要么:

OnClientClick="if (!Page_ClientValidate()){ return false; } this.disabled = true; this.value = 'Please wait...';" 
UseSubmitBehavior="false"

This ensures the button isn't disabled when there are validation errors. 这样可以确保在出现验证错误时不会禁用该按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM