隐藏组中的所有单选按钮

时间:2019-06-05 06:58:17

标签: c# asp.net

我应该禁用属于某个组的所有单选按钮

我有一个asp.net页面,其中包含多项检查。我应该确保根据列表框内选择的选项,隐藏或禁用某些单选按钮组。

<asp:DropDownList ID="modelTypeSelectIN" runat="server" AutoPostBack="true" OnSelectedIndexChanged="modelTypeSelect_SelectedIndexChanged">
<asp:ListItem Value="" Selected="True"> SELEZIONA IL TIPO DI FINITURA</asp:ListItem>
    <asp:ListItem Value="air_IN">AIR</asp:ListItem>
    <asp:ListItem Value="wide_IN">WIDE</asp:ListItem>
    <asp:ListItem Value="sound_IN">SOUND</asp:ListItem>
    <asp:ListItem Value="wave_IN">WAVE</asp:ListItem>
    <asp:ListItem Value="box_IN">BOX</asp:ListItem>
    <asp:ListItem Value="plana_IN">PLANA</asp:ListItem>
    <asp:ListItem Value="planaFG_IN">PLANA FULL GLASS</asp:ListItem>
</asp:DropDownList>


<div class="box" runat="server" id="BoxProva"><asp:RadioButton ID="sup3" GroupName="Superfici" runat="server" AutoPostBack="true" /><span><span class="img" runat="server"><img src="~/In/Superfici/AIR_SLIGHTGRAIN/AIR SLIGHTGRAIN_8016_IN LUCE.png" alt="" runat="server"></span>PROVA DI FILTRO</span><div class="image-box"><img src="~/In/Superfici/AIR_SLIGHTGRAIN/AIR SLIGHTGRAIN_8016_IN LUCE.png" alt="" runat="server"></div></div>

<div class="box" runat="server" id="BoxProva"><asp:RadioButton ID="sup4" GroupName="Superfici" runat="server" AutoPostBack="true" /><span><span class="img" runat="server"><img src="~/In/Superfici/AIR_SLIGHTGRAIN/AIR SLIGHTGRAIN_8017_IN LUCE.png" alt="" runat="server"></span>PROVA DI FILTRO</span><div class="image-box"><img src="~/In/Superfici/AIR_SLIGHTGRAIN/AIR SLIGHTGRAIN_8017_IN LUCE.png" alt="" runat="server"></div></div>

这是一个事件处理程序:

protected void SlightGrain7016InLuce_CheckedChanged(object sender, 
 EventArgs e)
    {
        if (SlightGrain7016InLuce.Checked)
        {
            BoxProva.Visible = false;
        }
    }

1 个答案:

答案 0 :(得分:0)

类似的东西会起作用,使用功能来管理您的单选按钮组...

        // Thsi will trigger When Dropdownlist selected option changed
    protected void modelTypeSelect_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (modelTypeSelectIN.SelectedItem.Text == "WIDE")
        {
            Disable_GroupSuperfici_RaddioButton();
        }
        else
        {
            Enable_GroupSuperfici_RaddioButton();
        }
    }

    // This function Enable particular group of button
    private void Disable_GroupSuperfici_RaddioButton()
    {
        sup3.Enabled = false;
        sup4.Enabled = false;
        //RadioButton1.Enabled = false;
        //RadioButton2.Enabled = false;
    }

    // This function disable particular group of button
    private void Enable_GroupSuperfici_RaddioButton()
    {
        sup3.Enabled = true;
        sup4.Enabled = true;
        //RadioButton1.Enabled = true;
        //RadioButton2.Enabled = true;
    }