Msxmania
Msxmania

Reputation: 53

How to check if Ajax Control Toolkit CollapsiblePanelExtender is collapsed using JQuery?

I've the following ASP.NET code:

<div id="pnlFiltros" class="card">
    <asp:Panel ID="pnlFiltrosHeader" runat="server" CssClass="card-header bg-verdepetrobras text-white">
        Filtros (<asp:Label ID="lblTextFiltros" runat="server" />)
    </asp:Panel>
    <asp:Panel ID="pnlFiltrosContent" runat="server" CssClass="card-body">
        <div class="form-row">
            <div class="form-group col-md-6">
                <label>Chave / Nome</label>
                <asp:TextBox ID="txtChaveNome" runat="server" CssClass="form-control" />
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-md-2">
                <asp:Button ID="btPesquisar" runat="server" CssClass="btn btn-primary" Text="Pesquisar" OnClick="btPesquisar_Click" />
            </div>
        </div>
    </asp:Panel>
</div>

<ajaxToolkit:CollapsiblePanelExtender ID="cpExtFiltros" runat="server" TargetControlID="pnlFiltrosContent" CollapseControlID="pnlFiltrosHeader" ExpandControlID="pnlFiltrosHeader"
    Collapsed="false" TextLabelID="lblTextFiltros" CollapsedText="Clique para exibir..." ExpandedText="Clique para esconder..."
    CollapsedSize="0"></ajaxToolkit:CollapsiblePanelExtender>

How can I check if Ajax Control Toolkit CollapsiblePanelExtender is collapsed using JQuery?

Upvotes: 0

Views: 287

Answers (2)

prashant
prashant

Reputation: 2165

There are few function that you can access via given behavior id

<ajaxToolkit:CollapsiblePanelExtender ID="LimitedByTypePanelExtender" runat="server" TargetControlID="LimitedByTypePanel" BehaviorID="bhvLimitedByType" Collapsed="true">
</ajaxToolkit:CollapsiblePanelExtender>

if you check the object $find('bhvLimitedByType') in chrome console you can see below and more methods in the prototype

enter image description here

So according to this, you can use to check whether panel is collapsed or not.

var isLimitedByCollapsed = $find('bhvLimitedByType').get_Collapsed();

Upvotes: 1

Msxmania
Msxmania

Reputation: 53

My workaround was to get the height of "pnlFiltrosContent". If it's 0px, the panel is collapsed.

            if ($('#<%=pnlPerfilContent.ClientID%>').css("height") == "0px")
                alert("Is collapsed");

Upvotes: 0

Related Questions