所以我要完成的工作是在勾选CheckBox时使面板显示出来。另外,当复选框未选中时,我想隐藏div / panel。 我在应用程序的VB.NET端有此行:
pnlWitness.Visible = False
If cbWitness.Checked = True Then
pnlWitness.Visible = True
End If
但是,当我勾选并取消选中复选框时,面板没有任何反应。我错过了什么吗?
编辑:这是我在ASP中的代码
<asp:Panel runat="server" ID="pnlWitness">
<div class="form-row">
<div class="form-group col-md-2">
<label id="lblWitnessName"><b>Name</b></label>
<asp:TextBox runat="server" type="text" class="form-control" id="tbWitnessName" style="width: 150px"></asp:TextBox>
</div>
<div class="form-group col-md-2" style="margin-right:15px">
<label id="lblWitnessGender"><b>Gender</b></label>
<select runat="server" id="cmbWitnessGender" class="form-control" style="width: 155px">
<option></option>
<option>Male</option>
<option>Female</option>
</select>
</div>
<div class="form-group col-md-2">
<label id="lblWitnessContactNo"><b>Contact Number</b></label>
<asp:TextBox runat="server" type="text" class="form-control" id="tbWitnessContactNo"></asp:TextBox>
</div>
</div>
<div class="form-group" style="margin-top: 15px">
<label id="lblWitnessRemarks"><b>Remarks</b></label>
<asp:TextBox runat="server" class="form-control" id="tbWitnessRemarks"></asp:TextBox>
</div>
</asp:Panel>
下面是我在VB中的代码:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
pnlWitness.Visible = False
If cbWitness.Checked = True Then
pnlWitness.Visible = True
End If
'Loads the Incident Type from DB
FillIncidentTypeCmb()
End Sub
答案 0 :(得分:0)
我可以通过在ASP端的面板中添加AutoPostBack="true"
来解决此问题。