mardi 20 novembre 2018

checkbox checked change will disabled the other checkbox

I have two checkboxes. If the first checkbox checked, the second checbox will be disabled and if the first checkbox unchecked, the second checkbox will be enabled.

<div class="data">
<asp:CheckBox ID="firstCheckBox" runat="server" CssClass="LabelText" EnableViewState="False" AutoPostBack="True" />
</div>

<div class="data">
<asp:CheckBox ID="secondCheckBox" runat="server" CssClass="LabelText" EnableViewState="False" AutoPostBack="True" />
</div>

Here is my control part at the Page_Load;

            if (firstCheckBox.Checked)
            {
                secondCheckBox.Enabled = false;

            }
            else
            {
                secondCheckBox.Enabled = true;
            }

When I checked the firstcheckbox, nothing happens to the secondcheckbox. After I checked the second checkbox, secondcheckbox has been checked and disabled.

What am I missing?




Aucun commentaire:

Enregistrer un commentaire