【问题标题】:Postback Happening inside UpdatePanel when CheckBox is Checked选中 CheckBox 时在 UpdatePanel 内发生回发
【发布时间】:2011-09-19 06:06:35
【问题描述】:

我有一个ListView,在其中我有一个CheckBox,其中AutoPostBack 设置为true,我还有一个可折叠面板保存在同一个ListView 中,与此@987654326 相邻@。

整个内容都保存在 UpdatePanel 中,用于 Silent Post 回复。现在我的问题是即使它保存在UpdatePanel 中,当我点击CheckBox 时,整个页面都在刷新。我需要使用 Silent PostBack 来完成。我怎样才能做到这一点??

<asp:ListView ID="ListViewGroups" runat="server" 
        onitemdatabound="ListView1_ItemDataBound">


    <EmptyDataTemplate>
        <table runat="server" style="">
            <tr>
                <td>
                    No data was returned.</td>
            </tr>
        </table>
    </EmptyDataTemplate>

    <ItemTemplate>
        <tr style="">
            <td>
            <asp:Panel ID="PanelContainer" runat="server" Width="400px">

                <asp:Panel ID="PanelHeaderList" runat="server" Width="20px">
                <div style="float:left;" >
                <asp:ImageButton ID="Image1" runat="server" 
                                 ImageUrl="~/expand_blue.jpg" 
                                 AlternateText="(Show Details...)"/>
                </div>
                 </asp:Panel>
                <div style="float:left;" >       
                    <asp:CheckBox ID="CheckBox1" runat="server" 
                                  AutoPostBack="true" />            
                <asp:Label ID="Grp_NameLabel" runat="server" 
                           Text='<%# Eval("Grp_Name") %>' />
                <asp:HiddenField ID="hfGrpID" runat="server" 
                                 Value='<%#Eval("Grp_ID") %>' />
                </div>
              <br />
                <p>
                <asp:Panel ID="PanelGroupsItem" runat="server" 
                           Width="100px" >
                <asp:Panel ID="MyGroups" runat="server" 
                           ScrollBars="Vertical" 
                           Height="200px" 
                           Width="300px" 
                           Visible='<%# GetFlag(Convert.ToInt32(Eval("Grp_ID"))) %>'>

                   //Another Normal gridView here just showing some data


                   </asp:Panel>
                </asp:Panel>

                <asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender1"
                                  runat="server"
                                  Collapsed="true"
                                  TargetControlID="PanelGroupsItem"
                                  CollapseControlID="PanelHeaderList"
                                  ExpandControlID="PanelHeaderList"
                                  ImageControlID="Image1"
                                  ExpandedImage="~/collapse_blue.jpg"
                                  CollapsedImage="~/expand_blue.jpg"
                                  SuppressPostBack="true"
                >
                </asp:CollapsiblePanelExtender>
                </asp:Panel>
                </p>
            </td>

        </tr>
    </ItemTemplate>
    <LayoutTemplate>
        <table runat="server">
            <tr runat="server">
                <td runat="server">
                    <table ID="itemPlaceholderContainer" runat="server" 
                           border="0" style="">
                        <tr runat="server" style="">
                            <th runat="server">
                                Groups</th>

                        </tr>
                        <tr ID="itemPlaceholder" runat="server">
                        </tr>
                    </table>
                </td>
            </tr>
            <tr runat="server">
                <td runat="server" style="">
                </td>
            </tr>
        </table>
    </LayoutTemplate>

</asp:ListView>

请帮帮我

【问题讨论】:

  • 更新面板上设置了哪些属性?
  • 我尝试了 Conditional 和 Always.. 但它不起作用。我没有设置任何其他属性
  • 您应该包含Updatepanel 的标记,因为它可能是导致问题的原因。此外,您所说的“静默回邮”也称为“AsyncPostBack”。

标签: asp.net ajax listview updatepanel postback


【解决方案1】:

我在这里找到了类似问题的解决方案:Checkboxlist inside UpdatePanel triggers full postback when an item is checked

您需要将复选框的ClientID模式设置为AutoID。

【讨论】:

    猜你喜欢
    • 2017-05-13
    • 2014-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-28
    • 2012-06-30
    • 1970-01-01
    相关资源
    最近更新 更多