简体   繁体   中英

How to check if checkbox is checked in other page

I have 2 pages. EditEventTicketsInfo.aspx and SummaryEvent.aspx
For 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%>

$(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. Now I want to check if chkHidePackage is checked, then hide the same value in SummaryEvent.aspx. Help please.

You can handle checked change event of your checkBox and then put value of checkstate in a session.

How hard was that?

You can complete this task in many way.

You can use Session variable , Cookies , Query string .

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 .

Hope you understand.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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