单击一次后防止按钮单击 [英] Prevent button click after clicked once

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

问题描述

我有一个保存数据的保存按钮.保存数据后,我从该页面重定向到另一个页面.问题是在重定向之前,如果我在该按钮上单击两次,则数据被保存了两次,我想防止这种情况的发生.一旦单击,直到重定向,用户在重定向到另一表格之前,将无法单击该按钮.如何执行此操作?有什么想法?

I have a save button for saving data.After saving data i redirect from that page to another page.The problem is before redirect if i click twice on that button the data gets saved twice.I want to prevent this from happening.once clicked until redirect the user should not be able to click on that button until redirecting to another form.How to do this?Any ideas?

推荐答案

document.getElementById("buttonID").onclick = function() {
    this.disabled = true;
}


好的,所以您有一个保存按钮...

让我们叫按钮button2&它将执行Save.all();
okay so you have a save button...

lets call the button button2 & it will execute Save.all();
bool CanSave = true

     private void button2_Click(object sender, EventArgs e)
       {

          if(CanSave == true)
             {
                Save.all();
                CanSave = false ;
                  }
                  else 
                {

                   MessageBox.Show("You cant multi save Please wait...");

                }
             }


       }                                                                          


除了禁用按钮外,可能还会显示一些消息,让用户知道他的请求正在处理中,这将向他保证,因此他将不会尝试再次点击.检查一下:使用ASP.NET按钮提交一次服务器控制 [ ^ ]
In addition to disabling the button, may be display some message to let the user knows that his request is being processed, that will assure him so he will not try to click again. Check this out: Submit Once with an ASP.NET Button Server Control[^]


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

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