我試圖取消隱藏一組單選按鈕,如果其上方的複選框被選中並且未勾選複選框時將其隱藏。我有一個以前的版本,在同一個應用程序,它工作得很好[單選按鈕打開復選框,而不是]在工作之一。當選擇MinorCheck
時,單選按鈕不可見。沒有錯誤顯示,沒有任何反應。爲什麼是這樣?當選擇複選框時,無線電組不會取消隱藏
我看過其他評論如何可見=「假」停止它等等。然而,很顯然,在開始時visible =「false」對於我的第一個編碼塊來說並不是問題。
一個參考我用:ASP.NET CheckBox does not fire CheckedChanged event when unchecking
工作之一:
HTML
<td class="LeftAlign" width="24%">
<font class="Blackfont" size="1">
<B> Union Affiliated?
</B>
</font>
<font class="WeOrangefont" size="1">
•
</font>
</td>
<td width="10%">
<asp:RadioButtonList ID="rblclass" runat="server" AutoPostBack="True" class="Bluefont" size="1" font-Bold="True" font-Size="8pt" >
<asp:ListItem Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N">No</asp:ListItem>
</asp:RadioButtonList>
</td>
<td></td>
</tr>
</table>
VB.NET
Protected Sub rblclass_SelectedIndexChanged(sender As Object, e As EventArgs) Handles rblclass.SelectedIndexChanged
If (rblclass.SelectedValue = "Y") Then
Register.Focus()
union1.Visible = True
union2.Visible = True
union3.Visible = True
LocalLbl.Visible = True
Reqimage.Visible = True
Else
Register.Focus()
union1.Visible = False
union2.Visible = False
union3.Visible = False
LocalLbl.Visible = False
Reqimage.Visible = False
End If
End Sub
編碼的其他部分並不即使它的工作很相似:
<tr>
<td class="LeftAlign" colspan="2">
<font class="Blackfont" size="1">
<asp:CheckBox ID="MinorCheck" runat="server" NAME="BUSINESSCLASSIFICATION"
class="ownerClass" value="000" checked = "false" TabIndex="32"/>
<asp:HyperLink ID="HyperLink2" runat="server" TABSTOP = "-1" onClick="OpenWindow('Images/Supp.html', 'Min Business Concern',600, 300, 'no')" font-Underline="True" ForeColor="#666666" >Minority Business Concern</asp:HyperLink>
</font>
</td>
</tr>
<tr>
<td>
<asp:RadioButtonList ID="RadioButtonBClass" runat="server" AutoPostBack="True"
class="Bluefont" size="1" font-Bold="True" font-Size="8pt" visible = "false">
<asp:ListItem Value="Y" >African-American male</asp:ListItem>
<asp:ListItem Value="N">African-American female</asp:ListItem>
<asp:ListItem Value="N">Asian-Indian American male</asp:ListItem>
<asp:ListItem Value="N">Asian-Indian American female</asp:ListItem>
<asp:ListItem Value="N">Asian-Pacific American male</asp:ListItem>
<asp:ListItem Value="N">Asian-Pacific American female</asp:ListItem>
<asp:ListItem Value="N">Native American male</asp:ListItem>
<asp:ListItem Value="N">Native American female</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
VB.NET
Protected Sub MinorCheck_CheckedChanged(sender As Object, e As EventArgs) Handles MinorCheck.CheckedChanged
If (MinorCheck.Checked = true) Then
RadioButtonBClass.Visible = True
NonMinorCheck.Checked = false
Else
RadioButtonBClass.Visible = False
End If
End Sub
當我發佈時,我對「MinorCheck」的True/False超過了,即使我的編碼沒有。無論如何,上述編碼目前不起作用 – narue1992