首页 > 解决方案 > 为什么我的 ajaxCollapsiblePanel 不工作

问题描述

我的 ajaxColpsiblePanelExtender 有一些问题。当我单击按钮时,它应该隐藏第二段。

<asp:Button runat="server" ID="_btnCollpasePanel" Text="Click Here to Collapse"/>
<table>
    <tr>
        <td style="border: solid 1px #7f9db9; width: 200px;">
            <p>Some collapsible content. Click the button to toggle between 
              showing and hiding the collapsible content.</p>
        </td>
    </tr>
    <tr>
        <asp:Panel runat="server" ID="sample">
            <ajax:CollapsiblePanelExtender runat="server" 
             ID="sampleCollapsiblePanel" TargetControlID="sample" 
             CollapseControlID="_btnCollpasePanel"
             ExpandControlID="_btnCollpasePanel" Collapsed="true">
            </ajax:CollapsiblePanelExtender>
            <td style="border: solid 1px #7f9db9; width: 200px;">
                <p>Some collapsible content. Click the button to toggle 
                   between showing and hiding the collapsible content.</p>
            </td>
        </asp:Panel>
    </tr>
</table>

标签: asp.net

解决方案


由于可折叠面板位于<td>元素之外。它不起作用。

<asp:Button runat="server" ID="_btnCollpasePanel" Text="Click Here to Collapse"/>
<table>
    <tr>
        <td style="border: solid 1px #7f9db9; width: 200px;">
            <p>Some collapsible content. Click the button to toggle between 
              showing and hiding the collapsible content.</p>
        </td>
    </tr>
    <tr>

        <td style="border: solid 1px #7f9db9; width: 200px;">
            <asp:Panel runat="server" ID="sample">
                <ajax:CollapsiblePanelExtender runat="server" 
                    D="sampleCollapsiblePanel" TargetControlID="sample" 
                    CollapseControlID="_btnCollpasePanel"
                    ExpandControlID="_btnCollpasePanel" Collapsed="true">
                </ajax:CollapsiblePanelExtender>
                <p>Some collapsible content. Click the button to toggle 
                  between showing and hiding the collapsible content.</p>
            </asp:Panel>
        </td>

    </tr>
</table>

推荐阅读