jqueryasp.netblockui

ASP.NET button jQuery-BlockUI


I'm not sure what I did wrongly the BlockUI isn't working. Hope you guys can help, Thanks.

I am trying to make after clicked the search button, the UI will unavailable from user.

 <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">


    <script src="../JS/jquery-1.9.1.js" type="text/javascript"></script>

    <script src="../JS/jquery.blockUI.js" type="text/javascript"></script>

    <script type="text/javascript">
     $(document).ready(function() {
     $('<%= btnSearch.ClientID %>').click(function() {
         $.blockUI({ message: 'Just a momeqweqwent...'});

     setTimeout(function() {
         $.unblockUI({
             onUnblock: function() { alert('onUnblock'); }
         });
     }, 2000);
   });
});
    </script>

<asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="Rect" OnClick="btnSearch_Click">
                </asp:Button>

Solution

  • Add hash symbol to btnSearch selector: $('#<%= btnSearch.ClientID %>')