.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Articles >> C# >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Disable a submit button during Post Back.

Posted By:Suthish Nair       Posted Date: August 29, 2010    Points: 25    Category: C#    URL: http://www.dotnetspark.com  

Most of the programmers facing the issue of, how to handle multiple button submits by user at the same time. This article will help you with a small sample. You can restrict multiple button submission by using method ClientScript.GetPostBackEventReference (for more information, please Bing/Google).






#code behind

protected void Page_Load(object sender, EventArgs e)


   String sString = "this.style.backgroundColor='skyblue'; this.style.color='Red'; this.value='Saving 

Records... Please Wait...'; this.disabled = true; {0};";

   String sHandler = String.Format(sString, this.ClientScript.GetPostBackEventReference(Button1, 


   Button1.Attributes.Add("onclick", sHandler);


   sHandler = "";

   sHandler = String.Format(sString, this.ClientScript.GetPostBackEventReference(Button2, 


   Button2.Attributes.Add("onclick", sHandler);


   sHandler = "";

   sHandler = String.Format(sString, this.ClientScript.GetPostBackEventReference(Button3, 


   Button3.Attributes.Add("onclick", "javascript:alert('hello');" + sHandler);



protected void Button1_Click(object sender, EventArgs e)






Second button will do a full post back. Third button, we can even attach JavaScript validation check before sHandler.

Button2: above same button effect, but a full post back will happen.

Button3: first it will show the alert followed by above same button effect.

Hope this article helped you. Please update your comments. You can also download the sample pages attached above.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend