Reputation: 103
I would like to turn off the dropdown PhoneHelp if phone is selected in the first dropdown box, but it doesn't seem to be working. Here is the code:
.net
<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
Thank you
Upvotes: 2
Views: 153
Reputation: 460048
You are disabling lblPhoneHelp
instead of ddlPhoneHelp
.
ddlPhoneHelp.Enabled = Not ddlHowRec.SelectedValue = "phone"
Upvotes: 3