How to use BlockUI


Here I will tell you how can you block user interface.Sometimes you need to block user activity with page until a certain process is completed. Jquery provides us a very easy way to do that.All you need to do is download jquery library and BlockUI plugin file.Here is an example how to block user activity.
<script src="Scripts/jquery-1.7.2.js" type="text/javascript"></script>
    <script src="Scripts/BlockUI.js" type="text/javascript"></script>
   
   <script type="text/javascript">
   $(document).ready(function () {
    $('#btnBlock').click(function () {
        $.blockUI({
        message: $('#Block_div'),
        css:
        {
        padding: 0,
        margin: 0,
        textAlign: 'center',
        fontSize: 12,
        cursor: 'auto',
        border: 'none',
        background:'none'
        }
     });
   });
   $('#Block_div').click(function()
   {
   $.unblockUI();
   });
});


    </script>
<div id="Block_div" style="width:100%; display:none;">
        <img src="Images/loading2.gif" title="Click here to unblock" />
    </div>
    <div>
    To block screen click on this button and to unblock screen click on div which appears after screen is blocked.
    <br />
    <input type="button" id="btnBlock" value="Block" />
    </div>


Let’s see in detail how to use it.Screen will be blocked when button is clicked.First thing in the BlockUI script is message: $('#Block_div') now this is name of the element which you want to display when screen is blocked I have aloding image in it you can use anything you want.Next you see some css properties these are optional if you do not want to use them you can skip them but you can get a good look if you use these properties.You can download BlockUI from here. http://jquery.malsup.com/block/#download

Comments

Popular posts from this blog

Check if ViewBag is null or doesn't exist

Using Progress Bar In C#

Jquery serer side datatables in asp.net