Checkboxlist inside UpdatePanel triggers full postback when an item is checked

泄露秘密 提交于 2019-12-12 11:40:54

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/11260567/checkboxlist-inside-updatepanel-triggers-full-postback-when-an-item-is-checked

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!