Search code examples
asp.netajaxwebformsupdatepanel

UpdatePanel AsyncPostbackTrigger not firing


I've got a little problem, any help is appreciated.

Situation looks like this:

<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>

When ddlSwitch selected index change I want to update content inside UP_Switch, but SelectedIndexChanged event doesn't seem to fire. What am I doing wrong?

Thanks in advance!


Solution

  • I have just tested your code and seems to be working with some test modifications: 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>
    

    Code behind for ddlSwitch_SelectedIndexChanged:

    protected void ddlSwitch_SelectedIndexChanged(object sender, EventArgs e)
    {
        litUpSwitch.Text = "DDL Switch go activated";
    }
    

    Result: