2

如果在第一个下拉框中选择了电话,我想关闭下拉电话帮助,但它似乎不起作用。这是代码:

。网

        <asp:DropDownList ID="ddlHowRec" runat="server">
            <asp:ListItem Value="" Text="Choose an option"></asp:ListItem>
            <asp:ListItem Value="mail" Text="Mail"></asp:ListItem>
            <asp:ListItem Value="e-mail" Text="E-mail"></asp:ListItem>
            <asp:ListItem Value="phone" Text="Call back"></asp:ListItem>
        </asp:DropDownList>


            <asp:Label ID="lblPhoneHelp" runat="server" AssociatedControlID="ddlPhoneHelp"></asp:Label>
        <asp:DropDownList ID="ddlPhoneHelp" runat="server">
            <asp:ListItem Value="" Text="Choose an option"></asp:ListItem>
            <asp:ListItem Value="yes" Text="Yes"></asp:ListItem>
            <asp:ListItem Value="no" Text="No"></asp:ListItem>
        </asp:DropDownList>

VB:

    Protected Sub ddlHowRec_SelectedIndexChanged(ByVal sender As Object, ByVal e As      System.EventArgs) Handles ddlHowRec.SelectedIndexChanged

    If ddlHowRec.SelectedValue = "phone" Then
        lblPhoneHelp.Enabled = False
    Else
        lblPhoneHelp.Enabled = True
    End If
 End Sub

谢谢

4

1 回答 1

3

您正在禁用lblPhoneHelp而不是ddlPhoneHelp.

ddlPhoneHelp.Enabled = Not ddlHowRec.SelectedValue = "phone"
于 2012-04-04T19:38:39.893 回答