禁用按钮单击后单击

本文关键字:单击 按钮 | 更新日期: 2023-09-27 18:13:43

我上传大文件到Amazon S3与进度条,我显示Jquery的进度条,下面这个一切正常,但有两个问题如果在处理过程中用户多次选择另一个文件或单击上传按钮,则进度条计数会增加我已经禁用了FileUpload控制按钮上传点击事件,但它没有禁用按钮上传控制

This is How I am doing:

protected void btnupload_Click(object sender, EventArgs e)
{
  if (FileVideoUpload.HasFile)
  {
       FileVideoUpload.Enabled = false;
       btnupload.Enabled = false;
       System.Threading.Thread.Sleep(8000);
       //Upload File on Amazon S3
       lblmsg.Text = "Video uploaded Successfully";
       FileVideoUpload.Enabled = true;
       btnupload.Enabled = true;
  }
}

我也试过了,但仍然没有禁用

按钮
protected void Page_Load(object sender, EventArgs e)
{
    btnupload.Attributes.Add("onclick", " this.disabled = true; " + ClientScript.GetPostBackEventReference(btnupload, null) + ";");
}

我也试过在JS中禁用它。我想在处理时禁用这两个控件

禁用按钮单击后单击

尝试使用Jquery:-

$('#FormId').one('submit', function() {
$(this).find('input[type="submit"]').attr('disabled','disabled');
 // find input type submit button or any other buttons which u want //
});

如果#btnupload实际上是您想要单击和禁用的按钮,请尝试此操作。我没听明白。

$('#btnupload').on('click',function(){
    $(this).prop('disabled',true);
});

和以后再次启用它使用:

$('#btnupload').prop('disabled',false);

你可以在点击事件时禁用它

 $('#btnupload').on('click',function(){
        $(this).prop('disabled','disabled');
    });