UpdatePanel AsyncPostbackTrigger 未触发
UpdatePanel AsyncPostbackTrigger not firing
我遇到了一些小问题,如有任何帮助,我们将不胜感激。
情况是这样的:
<asp:UpdatePanel ID="UP_Panel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlSwitch" runat="server" Width="250px" AutoPostback="true"
OnSelectedIndexChanged="ddlSwitch_SelectedIndexChanged">
<asp:ListItem Value="continent" Text="Continent"></asp:ListItem>
<asp:ListItem Value="region" Text="Region"></asp:ListItem>
<asp:ListItem Value="country" Text="Country"></asp:ListItem>
</asp:DropDownList>
<asp:UpdatePanel ID="UP_Switch" runat="server" UpdateMode="Conditional">
<ContentTemplate>
// Some content
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlSwitch" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>
当ddlSwitch选择的索引改变时我想更新UP_Switch里面的内容,但是SelectedIndexChanged
事件没有好像火了我做错了什么?
提前致谢!
我刚刚测试了您的代码,似乎正在使用一些测试修改:ASPX
<asp:UpdatePanel ID="UP_Panel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlSwitch" runat="server" Width="250px" AutoPostback="true"
OnSelectedIndexChanged="ddlSwitch_SelectedIndexChanged">
<asp:ListItem Value="continent" Text="Continent"></asp:ListItem>
<asp:ListItem Value="region" Text="Region"></asp:ListItem>
<asp:ListItem Value="country" Text="Country"></asp:ListItem>
</asp:DropDownList>
<asp:UpdatePanel ID="UP_Switch" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Literal ID="litUpSwitch" runat="server"></asp:Literal>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlSwitch" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>
ddlSwitch_SelectedIndexChanged
的隐藏代码:
protected void ddlSwitch_SelectedIndexChanged(object sender, EventArgs e)
{
litUpSwitch.Text = "DDL Switch go activated";
}
结果:
我遇到了一些小问题,如有任何帮助,我们将不胜感激。
情况是这样的:
<asp:UpdatePanel ID="UP_Panel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlSwitch" runat="server" Width="250px" AutoPostback="true"
OnSelectedIndexChanged="ddlSwitch_SelectedIndexChanged">
<asp:ListItem Value="continent" Text="Continent"></asp:ListItem>
<asp:ListItem Value="region" Text="Region"></asp:ListItem>
<asp:ListItem Value="country" Text="Country"></asp:ListItem>
</asp:DropDownList>
<asp:UpdatePanel ID="UP_Switch" runat="server" UpdateMode="Conditional">
<ContentTemplate>
// Some content
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlSwitch" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>
当ddlSwitch选择的索引改变时我想更新UP_Switch里面的内容,但是SelectedIndexChanged
事件没有好像火了我做错了什么?
提前致谢!
我刚刚测试了您的代码,似乎正在使用一些测试修改:ASPX
<asp:UpdatePanel ID="UP_Panel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlSwitch" runat="server" Width="250px" AutoPostback="true"
OnSelectedIndexChanged="ddlSwitch_SelectedIndexChanged">
<asp:ListItem Value="continent" Text="Continent"></asp:ListItem>
<asp:ListItem Value="region" Text="Region"></asp:ListItem>
<asp:ListItem Value="country" Text="Country"></asp:ListItem>
</asp:DropDownList>
<asp:UpdatePanel ID="UP_Switch" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Literal ID="litUpSwitch" runat="server"></asp:Literal>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlSwitch" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>
ddlSwitch_SelectedIndexChanged
的隐藏代码:
protected void ddlSwitch_SelectedIndexChanged(object sender, EventArgs e)
{
litUpSwitch.Text = "DDL Switch go activated";
}
结果: