How to disable a button in asp.net

{0 Comments}

If you want to disable button after click on button in asp.net, then following syntax will help you. In this a JavaScript disable function is added dynamically to asp.net button on load. So that now if you click first time it works and after this it will disable. Here we are using add function in which first parameter we are passing is the on click event and other is the parameter contains the disabling JavaScript syntax which will disable your button.

 C# |  copy code |? 
1
  protected void Page_Load(object sender, EventArgs e)
2
    {
3
        Button1.Attributes.Add("onclick", "this.disabled=true;");
4
    }

Leave a Comment

Your email address will not be published.