troubleshooting Question

How to dynamically disable buttons on a page after sending back to server?

Avatar of purplesoup
purplesoupFlag for United Kingdom of Great Britain and Northern Ireland asked on
2 Comments1 Solution143 ViewsLast Modified:
I've seen example code for submitting a form, but I want to disable all the buttons on my web form after it is sent back to the server - my attempt is below but it isn't working.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TestForDisableButtonsOnPage.WebForm1" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <script src=""></script> 
    <form id="form1" runat="server">
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
            <hr />
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
            <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
            <asp:Button ID="Button3" runat="server" Text="Button" OnClick="Button3_Click" />
            <asp:Button ID="Button4" runat="server" Text="Button" OnClick="Button4_Click" />
<script type="text/javascript">
    $(":button").keyup(function () {
        $(":button").prop('disabled', true);


using System;
using System.Threading;

namespace TestForDisableButtonsOnPage
    public partial class WebForm1 : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)

        protected void Button1_Click(object sender, EventArgs e)

        protected void Button2_Click(object sender, EventArgs e)

        protected void Button3_Click(object sender, EventArgs e)

        protected void Button4_Click(object sender, EventArgs e)


        private void ButtonClick(int i)
            Label1.Text = $"Button {i} was clicked";
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros