g_shockTan g_shockTan - 1 year ago 77
Vb.net Question

Show/Hide table when checkbox is checked

Is there a way to show/hide a table when checkbox is checked? I've done it with JavaScript, but would like to know if it can be done from code behind.

Protected Sub chkAccept1_CheckedChanged(sender As Object, e As System.EventArgs) Handles chkAccept1.CheckedChanged

If chkAccept1.Checked = True Then
tableID.Visible = True
tableID.Visible = False

End If

End Sub

Win Win
Answer Source

Yes, your code work. Please make sure that you have AutoPostBack="True"

<asp:CheckBox runat="server" ID="chkAccept1" AutoPostBack="True" />
<asp:Table ID="tableID" runat="server">
    <asp:TableRow ID="TableRow1" runat="server">
        <asp:TableCell ID="TableCell1" runat="server">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download