I'm working in C# and I need a button to become instantly disabled when a user clicks it. However, if I put as the very first line in the OnClick function
MyButton.Enabled = false;
it does nothing. The button remains enabled until it hits some sort of stop, whether it be the Catch block or the end of the function.
I was thinking that in VB/VBA you can use DoEvents() and that allows the code to catch up to itself. However, in C# there doesn't appear to be a DoEvents method.
This is a little different than the linked question, in that my OnClick code looks like:
OnClick="btnSubmit_Click"
and that user's OnClick code looks like:
onClick="this.disabled=true;
this.value='Sending…';
this.form.submit();"
When I tried to change my code to:
OnClick="this.disabled=true; btnSubmit_Click"
I got an error.
Compiler Error Message: CS1041: Identifier expected; 'this' is a keyword
How can I do this in a C#/asp.net environment?