views:

621

answers:

2

I have an asp.net ajax CollapsiblePanelExtender control on my page. The way this control is designed, you can specify one control to open the panel and another control to close it:

<ajaxToolkit:CollapsiblePanelExtender ID="cpe" runat="Server"
  TargetControlID="panelStuff"
  ExpandControlID="butToggle" CollapseControlID="butToggle" Collapsed="True"
  SuppressPostBack="true" />

If ExpandControlID and CollapseControlID are identical, as they are in this example, then the control toggles the panel open and closed.

But what I would like is another control (within panelStuff) that allows the user to close this panel. Ideally, I would like to specify:

CollapseControlID="butToggle,butClose"

Any ideas how to do this?

+1  A: 

One way to achieve this:

Assign a BehaviorID to the CollapsiblePanelExtender:

<ajaxToolkit:CollapsiblePanelExtender ID="cpe" runat="Server" 
  BehaviorID="cpeForBehavior"
  TargetControlID="panelStuff"
  ExpandControlID="butToggle" CollapseControlID="butToggle" Collapsed="True"
  SuppressPostBack="true" />

Create javascript function to execute desired behavior:

function closeCpe() {
    $find("cpeForBehavior")._doClose();
}

Execute function in event handler:

<input type="button" id="MyOtherButton" onclick="closeCpe();" />
HectorMac
Where did you find _doClose() ? Is there documentation somewhere for these sort of commands? what if I wanted to expand and not collapse? I'm guessing doOpen() would work but what if I didn't know.
adinas
adinas: I have to admit, I don't know where you would go to find documentation. These may be undocumented underlying support functions for the extender. That said, you can also use _doOpen() and _doToggle().
HectorMac
A: 

Thank you it worked

Nasir Hussain