Forum Moderators: open
Maybe there's a better way but I assumed I would use a hidden panel that I would make visible if a certain field is selected on the drop down...but I'm not having any luck.
Here is the form snippet:
<asp:DropDownList ID="ddHeardAboutUs" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddHeardAboutUs_SelectedIndexChanged">
<asp:ListItem>Billboard</asp:ListItem>
<asp:ListItem>Search Engine</asp:ListItem>
</asp:DropDownList><asp:panel id="searchenginedetail" runat="server" Visible="false">
<label for="user">Which Search Engine:</label>
<asp:DropDownList ID="Craigslist" runat="server">
<asp:ListItem>Google</asp:ListItem>
<asp:ListItem>Yahoo</asp:ListItem>
</asp:DropDownList>
</asp:panel>
Here is the code:
protected void ddHeardAboutUs_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (ddHeardAboutUs.SelectedItem.Text == "Search Engine")
{
searchenginedetail.Visible = true;
}
}
When I change dropdown list the page does reload but the hidden pannel never shows. Any thoughts...or a better way to do this?
Thanks!
One thing that might make your life easiser is the following, instead of:
if (ddHeardAboutUs.SelectedItem.Text == "Search Engine")
{
searchenginedetail.Visible = true;
}
searchenginedetail.Visible = (ddHeardAboutUs.SelectedItem.Text == "Search Engine");