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

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

Rate me:
Please Sign up or sign in to vote.
3.83/5 (3 votes)
25 Apr 2011CPOL 10.1K   2   3
Good, my solution is by using Client Javascript.aspx pagescript //by using jqueryfunction DocumentReady() { //Button disable...
Good, my solution is by using Client Javascript

.aspx page
<asp:Button ID="btnSave" runat="server" Text="Save" CssClass="btn DisableWhenClick"
                    CommandName="Save" OnClick="btnAction_Click" />


script //by using jquery
C#
function DocumentReady() {
    //Button disable when Click
    $(".DisableWhenClick").click(function() {
        $(this).attr("disabled", true);
        $(this).val("Processing...");
    });


OK, then any button you need to disable when submit, you just need to add class "DisableWhenClick"

Enjoy!

License

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


Written By
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralReason for my vote of 2 Disables other functionality; that i... Pin
SteveSM27-May-11 12:25
professionalSteveSM27-May-11 12:25 
GeneralThis alternative seems to disable the OnClick event. Pin
SteveSM25-May-11 16:32
professionalSteveSM25-May-11 16:32 
GeneralGood one! Pin
Sunasara Imdadhusen2-May-11 22:54
professionalSunasara Imdadhusen2-May-11 22:54 

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.