Click here to Skip to main content
15,915,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a page with multiple buttons.
When i click on a button, it triggers a SQL procedure and runs it.
Till that process finishes i want all the other buttons in the page to be disabled.
I use the below code but it disables only the button which i clicked and not the remaining buttons.

Please help!

C#
protected void Page_Load(object sender, EventArgs e)
		{
			this.DisableButtonOnPostBack(this.btnGo, "Wait...");
		}

		public void DisableButtonOnPostBack(Button button, string text)
		{
	button.Attributes["onclick"] =
	string.Format("this.value = '{0}';this.disabled = true;{1};",text,
                        button.Page.ClientScript.GetPostBackEventReference(button, null));
		}
	}


[Edit]Removed shouting[/Edit]
Posted
Updated 30-May-13 20:45pm
v2

In addition to solution 1 here is another link that can help you achieve with javascript.
ASP.Net Disable Buttons during AJAX Postback[^]
- Another approach if you want to apply -
You can disable mouse click while processing so you do not have to disable all the buttons. Please check the link for more info:
Disabling Mouse clicks while processing using Javascript[^]

Good luck,
OI
 
Share this answer
 
As demonstrated at Using the Controls Collection in an ASP.NET Web Page[^], you can use the Controls Collection on each page to disable buttons on that page.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900