简体   繁体   English

如何检查复选框是否在其他页面中被选中

[英]How to check if checkbox is checked in other page

I have 2 pages.我有 2 页。 EditEventTicketsInfo.aspx and SummaryEvent.aspx EditEventTicketsInfo.aspx 和 SummaryEvent.aspx
For EditEventTicketsInfo.aspx对于 EditEventTicketsInfo.aspx

<tr>
   <td style="width:170px;" ><div style="margin-top:-5px;">
    <div class="form-label">
      <span>Hide Package Information</span>:
    </div>
    </div>
   </td>
   <td class="test_cb_td"><div style="width:205px;"><div style="margin-top:-5px;">
      <div style="float:left;"><asp:CheckBox ID="chkHidePackage" AutoPostback="true" runat="server" checked="false" class="test_cb"></asp:CheckBox></div>
      </div>
   </td> 



 <asp:Label runat="server" id="pkg_visibility">
   <tbody id="pkg_container">
     <%=Packages%>
    </tbody>
</asp:Label>


Below is the script for hiding the <%=Packages%>下面是隐藏 <%=Packages%> 的脚本

$(document).ready(function () {
        $('.test_cb_td .test_cb .jqTransformCheckboxWrapper').find('.jqTransformCheckbox').click(function () {
            if ($('[id$=_chkHidePackage]').attr('checked')) {
                $('[id$=_chkHidePackage]').attr('checked', true);
                $("#pkg_visibility").val('');
                $("#pkg_container").attr("style", "visibility: hidden")
            } else {
                $('[id$=_chkHidePackage]').attr('checked', false);
                $("#pkg_container").attr("style", "visibility: visible")                }
        });
    });

This code is working as expected in EditEventTicketsInfo.aspx.此代码在 EditEventTicketsInfo.aspx 中按预期工作。 Now I want to check if chkHidePackage is checked, then hide the same value in SummaryEvent.aspx.现在我想检查是否选中了 chkHidePackage,然后在 SummaryEvent.aspx 中隐藏相同的值。 Help please.请帮忙。

You can handle checked change event of your checkBox and then put value of checkstate in a session.您可以处理 checkBox 的已检查更改事件,然后将 checkstate 的值放入会话中。

How hard was that?那有多难?

You can complete this task in many way.您可以通过多种方式完成此任务。

You can use Session variable , Cookies , Query string .您可以使用Session 变量Cookies查询字符串

Just set or pass the value of checkbox like if it's checked set or pass a boolean value true else false and then check that value in second page and apply the logic .只需设置或传递复选框的值,就像检查设置或传递布尔值 true else false 然后在第二页中检查该值并应用逻辑

Hope you understand.希望你能理解。

声明一个 boolean 或 int 变量并放置一个 if 块并在条件检查中,检查是否选中了复选框,如果条件显示为真,将变量的值从 0 更改为 1,并在稍后要检查的页面中复选框已选中,检查变量的值是否已从 0 更改为 1 如果是,则选中该复选框,否则未选中!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM