Currently, I have a dropdown menu that, when an item is selected, dynamically populates another dropdownmenu. 这在单独查看页面时完全正常,但是,当我在 iframe 中查看页面时,当我更改下拉菜单中的选项时没有任何反应。包含 iframe 的主页也有一个 updatePanel,我觉得可能存在某种路由问题?也许更新无法区分面板并被路由到主页中的面板?任何帮助表示赞赏!
主页上的代码看起来与主页相同,我正在创建一个项目,而在框架页面中,我正在更新一个项目。
编辑:更新 我做了一个测试页面,除了 iframe 之外什么都没有,但它仍然不起作用。似乎更新面板在我的 iframe 中加载时根本不起作用。
aspx:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<li>
<asp:DropDownList ID="CategorySelector" runat="server" AutoPostBack="True" OnSelectedIndexChanged="CategorySelector_SelectedIndexChanged">
<asp:ListItem Text="--Please Select--" Value="none"></asp:ListItem>
<asp:ListItem Text="Everything"></asp:ListItem>
<asp:ListItem Text="Product"></asp:ListItem>
<asp:ListItem Text="Brand"></asp:ListItem>
<asp:ListItem Text="Category"></asp:ListItem>
<asp:ListItem Text="SubCategory"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="CategorySelector" ForeColor="#FF3300" InitialValue="none">*</asp:RequiredFieldValidator>
</li>
<li>
<asp:DropDownList ID="ItemSelector" runat="server">
</asp:DropDownList></li>
</ContentTemplate>
</asp:UpdatePanel>
代码:
protected void CategorySelector_SelectedIndexChanged(object sender, EventArgs e)
{
if (CategorySelector.Text == "Product")
{
ItemSelector.DataSource = Product.GetAllActive();
ItemSelector.DataTextField = "Name";
ItemSelector.DataValueField = "ID";
ItemSelector.DataBind();
}
if (CategorySelector.Text == "Category")
{
ItemSelector.DataSource = Category.GetAllActive();
ItemSelector.DataTextField = "Name";
ItemSelector.DataValueField = "ID";
ItemSelector.DataBind();
}
if (CategorySelector.Text == "SubCategory")
{
ItemSelector.DataSource = SubCategory.GetAllActive();
ItemSelector.DataTextField = "Name";
ItemSelector.DataValueField = "ID";
ItemSelector.DataBind();
}
if (CategorySelector.Text == "Brand")
{
ItemSelector.DataSource = Brand.GetAllActive();
ItemSelector.DataTextField = "Name";
ItemSelector.DataValueField = "ID";
ItemSelector.DataBind();
}
if (CategorySelector.Text == "Everything")
{
ItemSelector.Items.Clear();
ItemSelector.Items.Add("Everything");
}
}