Syed Salman Raza Zaidi
Syed Salman Raza Zaidi

Reputation: 2192

Disable Button Click after clicking

I am uploading large file to Amazon S3 with Progress Bar, I am displaying Jquery progress bar, following This Every thing is working fine, but there are two problems If during processing user Select another file or Click Upload button multiple times, the progress bar count get increased I have disabled FileUpload Control on button upload click event, but its not disabling the button upload control

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;
  }
}

I also tried this,but still button is not disabling

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

Also I have tried disabling it in JS. I want to disable both controls while processing.

Upvotes: 0

Views: 1944

Answers (3)

Amit Kumar
Amit Kumar

Reputation: 5962

you can disable it on click event

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

Upvotes: 0

Amin Jafari
Amin Jafari

Reputation: 7207

try this if #btnupload is in fact the button that you want to be clicked and disabled. I didn't quiet get that.

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

and later for enabling it again use:

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

Upvotes: 1

Kartikeya Khosla
Kartikeya Khosla

Reputation: 18883

Try this with 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 //
});

Upvotes: 1

Related Questions