BrettDerry

Hi All,

I have an upload form that successfully emails an attachment in an email.

Once the user hits submit, I want the button to be disabled but the form to still do all the client-side validation and the server-side code to email the form etc.

Is there a 'quick and dirty' method to achieve this

Regards,
Brett


Re: Windows Forms General Disable button onclick to prevent multiple submissions

TilakGopi

Hi,

If i'm not wrong,

button.enabled = false - should be the first statement in the button_click event handler and

after this do all the client-side validation and the server-side code to email the form etc.

button.enabled =true - this u can when ever u want,by default it should be at the end of the handler also(if required).

This way u can avoid multiple clicking thereby submissions.

Thanx,

Ch.T.Gopi Kumar.






Re: Windows Forms General Disable button onclick to prevent multiple submissions

ctusch

Yep, as TilakGopi has said, you can gray out the button by setting its Enabled property to false. But I would do all the upload stuff in an additional thread and not in the onClick event handler because otherwise your program won't respond anymore, till all the uploading is finished (but I guess you already have it that way). So set Enabled to false in the OnClick event handler and implement a second event handler (OnUploadComplete or something, I don't know how you upload your data, so I dont know which events the class provides) where you set Enabled to true again.