选中复选框后,有没有办法显示/隐藏表格?我用JavaScript做过,但想知道是否可以通过代码完成。
Protected Sub chkAccept1_CheckedChanged(sender As Object, e As System.EventArgs) Handles chkAccept1.CheckedChanged
If chkAccept1.Checked = True Then
tableID.Visible = True
Else
tableID.Visible = False
End If
End Sub
答案 0 :(得分:1)
是的,您的代码有效。请确保您拥有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">
test
</asp:TableCell>
</asp:TableRow>
</asp:Table>