1

How to set a two buttons for CollapsiblePanelExtender in ASP.NET?

Say, I have panel with Image and a text separated by some text. I want my Image and a text to be the trigger to expand/collapse my Panel.

rob waminal
  • 18,117
  • 17
  • 50
  • 64

1 Answers1

0

Add ImageButtion as ExpandControl and use textbox keyup event to expand extender on client side:

function expand() {
    var extender = $find("CollapsibleExtender1");
    if (extender.get_Collapsed()) {
        $find("CollapsibleExtender1").expandPanel();
    }
}

<asp:Panel runat="server" ID="CollapsiblePanel">
        Cursus et amet cras egestas, turpis cras tempor diam scelerisque habitasse in, platea
        augue turpis. Odio? Risus, ultricies! Dapibus risus sit. Placerat et in parturient
        tristique, natoque porttitor, platea aenean, a, platea etiam urna, a cum nunc! Parturient
        platea, sit mauris proin, magna lacus, eros, in sed nascetur tempor adipiscing.
    </asp:Panel>
    <asp:ImageButton runat="server" ID="MyImageButton" ImageUrl="~/Images/infoindicator.gif" />&nbsp;
    <asp:Button runat="server" ID="MyButton" Text="Click Me" OnClientClick="expand(); return false;" />
    <ajax:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server" BehaviorID="CollapsibleExtender1"
        ExpandControlID="MyImageButton" Collapsed="true" TargetControlID="CollapsiblePanel"
        CollapsedText="Collapsed" ExpandedText="Expanded" SuppressPostBack="true" />
Yuriy Rozhovetskiy
  • 22,270
  • 4
  • 37
  • 68
  • each button must toggle the same panel. – rob waminal Jul 18 '11 at 08:52
  • which buttons? Could you clarify your question: do you want to set two buttons as expandcontrols for extender or you need expand it by button click and textbox keyup. It's some mismatch between your question title and description. – Yuriy Rozhovetskiy Jul 18 '11 at 08:57
  • first its not a text box, just a text and an image (both could be a button) and both can expand and collapse the same panel. – rob waminal Jul 18 '11 at 08:59