为服务器端复选框触发Javascript

Trigger Javascript for a Server side Checkbox

本文关键字:Javascript 复选框 服务器端      更新时间:2023-09-26

我有一个情况,我正在执行一些服务器操作的复选框的点击,然后将用户重定向到另一个页面。但问题是,在我点击复选框后,它需要时间来重定向,因为它有点慢,因此用户能够点击其他复选框。我想禁用整个页面或禁用所有复选框。我写了一个javascript,但只有当页面再次加载时才会触发。

我的Html:

   <div> 
    <asp:CheckBox ID="checkbox1" runat="server" OnCheckedChanged="checkbox1_CheckedChanged" AutoPostBack="true"  CssClass="chk-facet-checkbox"/>
    <asp:CheckBox ID="checkbox2" runat="server" OnCheckedChanged="checkbox2_CheckedChanged" AutoPostBack="true"  CssClass="chk-facet-checkbox"/>
    <asp:CheckBox ID="checkbox3" runat="server" OnCheckedChanged="checkbox3_CheckedChanged" AutoPostBack="true"  CssClass="chk-facet-checkbox"/>
    </div>
<div id='blockerdiv'>
</div> 

My Jquery:

    if ($(".chk-facet-checkbox").is(":checked")) {
      $('.blockerdiv').show();
//Code to show the 'blockerdiv' as an overlay blocking the whole page
// All we need to do is show the blockerdiv. There is already Code to take care of the overlay
  }

尝试添加:

$(".chk-facet-checkbox").attr("disabled", true);

and so:

if ($(".chk-facet-checkbox").is(":checked")) {
      $('.blockerdiv').show();
//Code to show the 'blockerdiv' as an overlay blocking the whole page
// All we need to do is show the blockerdiv. There is already Code to take care of the overlay
     $(".chk-facet-checkbox").attr("disabled", true);
  }

禁用该类的所有复选框输入

你可以使用jquery.blockui.js

然后使用$。block $。unblockUI函数可根据需要阻塞和解除阻塞UI。