0

I have run into an issue I am having a hard time explaining.

I am working on improving an existing solution and I am seeing behavior with my dropdowns that I was not expecting. It seems they are always doing a full page postback even though they are set to be async. They are inside of a repeater.

Here is my repeater in my update panel.

 <asp:UpdatePanel runat="server" ID="upnlPartSelector" ChildrenAsTriggers="true" UpdateMode="Always" Visible="false">
<ContentTemplate>
    <div class="product-page">
        <div class="row">

            <asp:Repeater runat="server" ID="rptFilterCategories" OnItemDataBound="RptCategories_ItemDataBound" OnItemCreated="rptFilterCategories_ItemCreated">
                <HeaderTemplate>
                    <div class="filter-selection">
                </HeaderTemplate>
                <ItemTemplate>
                    <div class="title">
                        <%# Eval("CategoryName") %>
                    </div>
                    <div class="select">
                        <asp:DropDownList CssClass="form-control" runat="server" ID="ddlFilterItems" AutoPostBack="true" DataTextField="Display" DataValueField="Value" OnSelectedIndexChanged="ddlFilterItems_SelectedIndexChanged"/>
                    </div>
                </ItemTemplate>
                <FooterTemplate>
                    </div>
                </FooterTemplate>
            </asp:Repeater>
    </div>
</ContentTemplate>

I am registering the dropdowns as async triggers on the repeaters OnItemCreated method.

 protected void rptFilterCategories_ItemCreated(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            var control = e.Item.FindControl("ddlFilterItems");
            ScriptManager.GetCurrent(Page).RegisterAsyncPostBackControl(control);
        }
    }

And yet still they are doing a full page postback instead of just updating the panel. Do I need to set the repeater as a trigger for the update panel? Or specifically say which update panel the Async Postback Control connects with?

1 Answers1

0

Have you tried adding the trigger in html to see if that makes it work correctly? And temporarily comment out the RegisterAsyncPostBackControl in the code behind.

</ContentTemplate>
<Triggers> 
    <asp:AsyncPostBackTrigger ControlID="ddlFilterItems" EventName="SelectedIndexChanged" /> 
</Triggers> 
Rick S
  • 6,476
  • 5
  • 29
  • 43
  • Figured it out. Seems like the solution I have been trying to improve overrides the default script manager (for who knows what reason). So i had to call custom code to get the script manager to actually register the trigger. – Nathastings Feb 19 '15 at 18:45