Dynamic creation of collapsiblepanel

G

gopijm

I am trying to dynamically create a Ajax toolkit CollapsiblePanel. can anybody please share a sample with me or give me some pointers
thanks,
GJM
 
J

Jonathan Parker

I take it you mean you want to create on of these controls:

http://ajax.asp.net/ajaxtoolkit/CollapsiblePanel/CollapsiblePanel.aspx

at runtime.

To do this replace this in the .aspx file:

<asp:panel ID="panelExtenderContainer" runat="server">

<ajaxToolkit:CollapsiblePanelExtender ID="cpp" runat="Server"
TargetControlID="ContentPanel"
ExpandControlID="Panel"
CollapseControlID="Panel"
ScrollContents="False"
Collapsed="False"
ExpandDirection="Vertical"
SuppressPostBack="true"
TextLabelID="TextLabel"
CollapsedText="Collapsed"
ExpandedText="Opened" />

</asp:panel>

with this in the aspx.cs file:

protected void Page_Load(object sender, EventArgs e)
{
CollapsiblePanelExtender collapsiblePanelExtender = new
CollapsiblePanelExtender();

collapsiblePanelExtender.TargetControlID = this.ContentPanel.ID;
collapsiblePanelExtender.ExpandControlID = this.Panel.ID;
collapsiblePanelExtender.CollapseControlID = this.Panel.ID;
collapsiblePanelExtender.ScrollContents = false;
collapsiblePanelExtender.Collapsed = false;
collapsiblePanelExtender.ExpandDirection =
CollapsiblePanelExpandDirection.Vertical;
collapsiblePanelExtender.SuppressPostBack = true;
collapsiblePanelExtender.TextLabelID = this.TextLabel.ID;
collapsiblePanelExtender.CollapsedText = "Collapsed";
collapsiblePanelExtender.ExpandedText = "Opended";

this.panelExtenderContainer.Controls.Add(collapsiblePanelExtender);
}

HTH

Jonathan.
 
J

jmgopi

Thanks Jonathan,

I was able to do that, but when I say
collapsiblePanelExtender.Collapsed = true; I do not get anything when
I click on the extender. But on the other hand if
collapsiblePanelExtender.Collapsed = false; it works perfectly.
Also by the way I have a asp:repeater inside each of the created
collapsiblePanelExtender.
Any Idea why this is happening?

Regards,
Gopi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top