Ajax Control Toolkit CollapsiblePanel扩展了页面上的所有控件

时间:2013-03-01 08:45:22

标签: c# asp.net listview asp.net-ajax ajaxcontroltoolkit

我目前在我的代码中有两个ListView控件,一个用于显示产品,另一个用于显示价格不同的产品变体。我的可折叠面板放在第二个ListView内。当在加载的网页上单击第一个可折叠面板时,所有可折叠面板都会展开(关闭也可以)。当点击任何其他可折叠面板(除了第一个面板)之外,什么都不会发生。 我已经尝试将id分配给目标面板,并收到一条错误消息,指出在运行时无法将id分配给控件。

以下是第二个listview的一些示例代码:

<LayoutTemplate>

<asp:Panel ID="pnlMoreProducts" runat="server" >
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>                            
</asp:Panel>

<div id="productCollDiv" class="productCollPanel">
<asp:Label ID="lblCollPanel" CssClass="lblCollPanel" runat="server" ></asp:Label>
                        </div>

<ajaxToolkit:CollapsiblePanelExtender ID="cpeMoreProducts" AutoCollapse="false" runat="server" TargetControlID="pnlMoreProducts"
                            CollapsedSize="0" Collapsed="true" TextLabelID="lblCollPanel" CollapsedText="Show More Products" ExpandedText="Hide Products"
                            ExpandDirection="vertical" ExpandControlID="productCollDiv" CollapseControlID="productCollDiv" SuppressPostBack="true" />
                    </LayoutTemplate>

任何帮助将不胜感激。 感谢。

1 个答案:

答案 0 :(得分:1)

尝试使用此模板:

<asp:Panel ID="pHeader1" runat="server" CssClass="cpHeader">
    <asp:Label ID="lblHeaderText1" runat="server" />
</asp:Panel>
<asp:Panel ID="pBody1" runat="server" CssClass="cpBody">
    <asp:Label ID="lblBodyText1" runat="server" />
</asp:Panel>
<act:CollapsiblePanelExtender ID="cpe1" runat="server" TargetControlID="pBody1" CollapseControlID="pHeader1"
    ExpandControlID="pHeader1" Collapsed="false" TextLabelID="lblHeaderText1" CollapsedText="Open..."
    ExpandedText="Close..." CollapsedSize="0" ExpandedSize="200"
    ScrollContents="true">
</act:CollapsiblePanelExtender>

<asp:Panel ID="pHeader2" runat="server" CssClass="cpHeader">
    <asp:Label ID="lblHeaderText2" runat="server" />
</asp:Panel>
<asp:Panel ID="pBody2" runat="server" CssClass="cpBody">
    <asp:Label ID="lblBodyText2" runat="server" />
</asp:Panel>
<act:CollapsiblePanelExtender ID="cpe2" runat="server" TargetControlID="pBody2" CollapseControlID="pHeader2"
    ExpandControlID="pHeader2" Collapsed="false" TextLabelID="lblHeaderText2" CollapsedText="Open..."
    ExpandedText="Close..." CollapsedSize="0" ExpandedSize="200"
    ScrollContents="true">
</act:CollapsiblePanelExtender>