how do I disable Button asp.net

后端 未结 4 2219
旧时难觅i
旧时难觅i 2021-02-12 10:57

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.

4条回答
  •  悲哀的现实
    2021-02-12 11:20

    You can use the client-side onclick event to do that:

    yourButton.Attributes.Add("onclick", "this.disabled=true;");
    

    or

    You can do this with javascript. in your form tag,

    onsubmit="javascript:this.getElementById("submitButton").disabled='true';"
    

    or

    In code behind file you can do like this

    button1.enabled = false 
    

提交回复
热议问题