Ok, let me preface this question with the fact that I have read through about all the articles on this website and tried the majority of these solutions.
I have a button that has a server side event. This server side event has a (handles btnSave_click).
My first attempt was of course this. :
btnSave.enable = false
This was of course not fast enough.
Then I tried this. :
btnSave.Attributes.Add("onclick", "this.disabled=true;");
and this. :
btnSave.Attributes.Add("onclick", " this.disabled = true; " + ClientScript.GetPostBackEventReference(btnSave, Nothing) + ";")
This did not work, of course then I tried a bunch of different jquery and javascript via the OnClientClick event. This did not work either, but from what I could see it was due to the fact that I have that server side event firing also, I wasn’t hitting my functions during stepthrough. As you can see I have spent a ton of time trying to get this to work. Hoping someone has an idea as to what I am doing incorrectly here. What I have is a very simple button and codebehind really nothing extravagant.
Here is my button. :
<asp:Button ID="btnSave" runat="server" Width="60px" Text="Save" Enabled="False"></asp:Button>
Here is the server side event header. :
Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
Again any ideas are greatly appreciated. Thanks.
When you click on button and disable it with javascript it is disabled on client and server side does not know it is disabled on client as server side checks the viewstate for control properties. If you want to keep it disabled after being clicked and postback then you have to disable it on both client and server.
On client end
On server end