65.9K
CodeProject is changing. Read more.
Home

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

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.80/5 (18 votes)

Apr 20, 2011

CPOL
viewsIcon

56413

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

Add the following lines on .aspx page:
<asp:Button ID="btnProcess" runat="server" onclick="btnProcess_Click"
            Text="Process" />
Add the following line on .aspx.cs page (Page_Load).
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