Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checkboxlist inside UpdatePanel triggers full postback when an item is checked

So I have this Checkboxlist and I want to implement a Select All feature for the elements inside it. I placed it inside an UpdatePanel, but everytime I click an item, the entire page is reloaded. This is my code:

 <asp:UpdatePanel ID="CBLPanel" runat="server" UpdateMode="Conditional"     ChildrenAsTriggers="false">
            <ContentTemplate>
                <div class="LeftAligned">
                    <asp:Label ID="FilterLabel" runat="server" Text="Filter by:" />
                    <asp:DropDownList runat="server" ID="FilterDDL" AutoPostBack="true" OnSelectedIndexChanged="FilterDDL_SelectedIndexChanged" />
                    <asp:ImageButton ID="FB" runat="server" ImageUrl="~/images/filter.png" AlternateText="VALUE"
                        CssClass="filter_button" OnClick="FB_Click" />
                    <div onmouseout="javascript:bMouseOver=false;" onmouseover="javascript:bMouseOver=true;"
                        class="filter_div">
                        <asp:CheckBoxList AutoPostBack="true" ID="FilterCheckBoxList" ClientIDMode="Static"
                            runat="server" CssClass="filter_checklist collapsed" OnSelectedIndexChanged="FilterCheckBoxList_Selected">
                        </asp:CheckBoxList>
                    </div>
                </div>
            </ContentTemplate>
                    </asp:UpdatePanel>

I though I should set ChildrenAsTriggers to false and this way I would update only from the code, but it doesn't seem to work.

like image 267
Gratziani V. Avatar asked Dec 21 '22 19:12

Gratziani V.


1 Answers

This looks like a familiar .NET Bug. Setting ClientIDMode=Auto on the CheckBoxList should fix it

like image 86
graham mendick Avatar answered Apr 26 '23 23:04

graham mendick