Click here to Skip to main content
15,885,216 members
Articles / Web Development / ASP.NET
Tip/Trick

Disable button after click and display text [Processing...]

Rate me:
Please Sign up or sign in to vote.
4.80/5 (21 votes)
8 Feb 2012CPOL 54K   25   20
Disable button after click and display text [Processing...]
Add the following lines on .aspx page:
XML
<asp:Button ID="btnProcess" runat="server" onclick="btnProcess_Click"
            Text="Process" />


Add the following line on .aspx.cs page (Page_Load).
C#
string strProcessScript = "this.value='Processing...';this.disabled=true;";
        btnProcess.Attributes.Add("onclick", strProcessScript + ClientScript.GetPostBackEventReference(btnProcess, "").ToString());


This will disable Button, and then change the text of the button "Processing...", and then continue on with the server side event btnProcess_OnClick event handler.

Thanks,
Imdadhusen

License

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


Written By
Technical Lead Infostretch Ahmedabad-Gujarat
India India
Aspiring for a challenging carrier wherein I can learn, grow, expand and share my existing knowledge in meaningful and coherent way.

sunaSaRa Imdadhusen


AWARDS:

  1. 2nd Best Mobile Article of January 2015
  2. 3rd Best Web Dev Article of May 2014
  3. 2nd Best Asp.Net article of MAY 2011
  4. 1st Best Asp.Net article of SEP 2010


Read More Articles...

Comments and Discussions

 
GeneralReason for my vote of 5 good one Pin
Nikhil_S27-Feb-12 18:46
professionalNikhil_S27-Feb-12 18:46 
GeneralRe: Reason for my vote of 5good one Pin
Sunasara Imdadhusen22-Apr-14 4:09
professionalSunasara Imdadhusen22-Apr-14 4:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.