Click here to Skip to main content
15,881,380 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 53.9K   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

 
QuestionClientScript not defined Pin
Ciupaz30-May-13 3:53
Ciupaz30-May-13 3:53 
AnswerRe: ClientScript not defined Pin
Sunasara Imdadhusen22-Apr-14 4:06
professionalSunasara Imdadhusen22-Apr-14 4:06 
QuestionRequired Field and Custom validations present on page which are linked to button click. Pin
kaushalmehra11-Jan-13 0:48
kaushalmehra11-Jan-13 0:48 
AnswerRe: Required Field and Custom validations present on page which are linked to button click. Pin
Sunasara Imdadhusen22-Apr-14 4:06
professionalSunasara Imdadhusen22-Apr-14 4:06 
GeneralExcellent Pin
marvelusexpy15-Nov-12 2:10
marvelusexpy15-Nov-12 2:10 
GeneralRe: Excellent Pin
Sunasara Imdadhusen22-Apr-14 4:07
professionalSunasara Imdadhusen22-Apr-14 4:07 
GeneralMy vote of 5 Pin
Savalia Manoj M7-Nov-12 1:10
Savalia Manoj M7-Nov-12 1:10 
GeneralRe: My vote of 5 Pin
Sunasara Imdadhusen22-Apr-14 4:07
professionalSunasara Imdadhusen22-Apr-14 4:07 
GeneralRe: My vote of 5 Pin
Sunasara Imdadhusen22-Apr-14 4:08
professionalSunasara Imdadhusen22-Apr-14 4:08 
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 
GeneralReason for my vote of 5 very useful Pin
CS14016-Feb-12 18:33
CS14016-Feb-12 18:33 
GeneralRe: Reason for my vote of 5very useful Pin
Sunasara Imdadhusen22-Apr-14 4:10
professionalSunasara Imdadhusen22-Apr-14 4:10 
GeneralReason for my vote of 1 gh,hl Pin
Nitish01nick28-Jun-11 21:30
Nitish01nick28-Jun-11 21:30 
GeneralRe: Reason for my vote of 1gh,hl Pin
Sunasara Imdadhusen22-Apr-14 4:11
professionalSunasara Imdadhusen22-Apr-14 4:11 
Generalreally Excelent Pin
Mohammed Fayed25-Apr-11 21:54
Mohammed Fayed25-Apr-11 21:54 
GeneralRe: really Excelent Pin
Sunasara Imdadhusen22-Apr-14 4:11
professionalSunasara Imdadhusen22-Apr-14 4:11 
GeneralExcellent tip! Pin
DrABELL24-Apr-11 13:09
DrABELL24-Apr-11 13:09 
GeneralRe: Excellent tip! Pin
Sunasara Imdadhusen22-Apr-14 4:11
professionalSunasara Imdadhusen22-Apr-14 4:11 
GeneralRe: Excellent tip! Pin
DrABELL22-Apr-14 9:02
DrABELL22-Apr-14 9:02 

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.