Wednesday, December 29, 2010

How to implement busy cursor in web forms by JQuery?

No validation:

            <asp:Button UseSubmitBehavior="false" OnClientClick="$('body').css('cursor', 'wait'); $('.Buttons').attr('disabled', 'true');"
                ID="ButtonBack" runat="server" Text="aa" ValidationGroup="novalidation"
                OnClick="ButtonBack_Click" />


With validation 

            <asp:Button UseSubmitBehavior="false" OnClientClick='if (Page_ClientValidate("vg")) { $("body").css("cursor", "wait"); $(".Buttons").attr("disabled", "true");}; '
                ID="ButtonReview" runat="server" Text="Next" OnClick="ButtonReview_Click"
                ValidationGroup="vg" />


And also add following code into master page or web forms page to reset cursor to normal, if validation failed
    <script type="text/javascript">
        function pageLoad() {
   $('body').css('cursor', 'auto');
        } 
    </script>



No comments:

Post a Comment