<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TestForDisableButtonsOnPage.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<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" />
</div>
</form>
<script type="text/javascript">
$(":button").keyup(function () {
$(":button").prop('disabled', true);
});
</script>
</body>
</html>
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)
{
ButtonClick(1);
}
protected void Button2_Click(object sender, EventArgs e)
{
ButtonClick(2);
}
protected void Button3_Click(object sender, EventArgs e)
{
ButtonClick(3);
}
protected void Button4_Click(object sender, EventArgs e)
{
ButtonClick(4);
}
private void ButtonClick(int i)
{
Label1.Text = $"Button {i} was clicked";
Thread.Sleep(5000);
}
}
}
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”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.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.