且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

单击一次后防止按钮单击

更新时间:2023-12-02 09:15:52

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[^]