本文介绍了如何开发具有隐藏和显示3个面板功能的复选框列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
asp.net代码
asp.net code
<div class="row">
<cc1:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="MultiSelectDDL" PopupControlID="PanelPopUp" >
</cc1:HoverMenuExtender>
<asp:DropDownList ID="MultiSelectDDL" TabIndex="0" Class="for-control"
runat="server"
onselectedindexchanged="MultiSelectDDL_SelectedIndexChanged1">
<asp:ListItem Value="all">Select Language for Question</asp:ListItem>
</asp:DropDownList>
<asp:Panel ID="PanelPopUp" CssClass="popupMenu" runat="server">
<asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="true"
onselectedindexchanged="CheckBoxList1_SelectedIndexChanged">
<asp:ListItem Value="l1">Marathi</asp:ListItem>
<asp:ListItem Value="l2">Hindi</asp:ListItem>
<asp:ListItem Value="l3">English </asp:ListItem>
</asp:CheckBoxList>
</asp:Panel>
</div>
C#代码
C# code
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
for (var i = 0; i < 3; i++)
{
if (CheckBoxList1.SelectedIndex == 0)
{
Panelmarathi.Visible = true;
}
else if (CheckBoxList1.SelectedIndex == 0 && CheckBoxList1.SelectedIndex == i)
{
Panelmarathi.Visible = true;
Panelhindi.Visible = true;
}
else if (CheckBoxList1.SelectedIndex == 0 && CheckBoxList1.SelectedIndex == i)
{
Panelmarathi.Visible = true;
Panelenglish.Visible = true;
}
}
推荐答案
if (A) { ... }
else if (A && B) { ... }
else if (A && B) { ... }
所以...如果它不是A,它会做什么?什么都没有...
即使它确实有类似的条件(我不确定它们是什么),条件执行的代码只会使事情可见,它不会试图隐藏任何东西。因此,任何事情都不会消失。
So...if it's not A, what does it do? Nothing...
And even if it did have something like the right conditions (and I'm not sure what they are) the conditionally executed code only makes things visible, it doesn't try to hide anything. So nothing will ever disappear either.
这篇关于如何开发具有隐藏和显示3个面板功能的复选框列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!