Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I disable Button asp.net

Tags:

How can I disable or enable button in asp.net? I want to disable button after click to prevent double click. I am trying to disable my Login button after clicking on it.

like image 779
Amol Avatar asked Nov 24 '12 05:11

Amol


People also ask

How can I disable the button?

To disable a button using only JavaScript you need to set its disabled property to false . For example: element. disabled = true . And to enable a button we would do the opposite by setting the disabled JavaScript property to false .

How do I disable a button web form?

Answers. If you just want to disable it and nothing else, then add attribute Enabled = "false".


1 Answers

You have to disable it on client so that user could not click it again.

<asp:button id="btn" runat="server" OnClientClick="this.disabled=true;"...... 

To disable on server side asp.net code.

btn.Enabled = false; 
like image 104
Adil Avatar answered Sep 21 '22 06:09

Adil