Search code examples
jqueryasp.netpostbackblockui

Postback in Block UI using Jquery


I use a blockui jquery in my webpage.
The issue is its not taking the settimeout function when it is postback.
It just blocks only for few seconds. I tried from the d site. http://malsup.com/jquery/block/#page
and tried many alternative ways like ajaxStart and ajaxstop events too.
It doesn't take the time when the page is postback.My code as

<script type="text/javascript">
        $(document).ready(function () {
            $('#demo10').click(function () {
                $.blockUI({
                    message: '<h1>Auto-Unblock!</h1>'
                });
                setTimeout($.unblockUI, 8000); 
            });
        }); </script>

    <div>
    <asp:Button ID="demo10" runat="server" Text="Run" />
    </div>

Solution

  • Your issue is probably because you let the click make post back. Return false on the click event to prevent it as:

      $(document).ready(function () {
                $('#demo10').click(function () {
                    $.blockUI({
                        message: '<h1>Auto-Unblock!</h1>'
                    });
                    setTimeout($.unblockUI, 8000); 
    
                    return false;
                });
            }); 
    

    In the page with the examples the button is not input control, and not product post back, thats why on the sample code did not use this return false; In your case your button rendered as input control, and this make post back.