Reputation: 187
I'm trying to create Accordian Controlls Dynammically on Page Load, code wise this is what I have so far:
// Create dynamic acordian control
AjaxControlToolkit.Accordion info = new AjaxControlToolkit.Accordion();
AjaxControlToolkit.AccordionPane infoPane = new AjaxControlToolkit.AccordionPane();
info.ID = hostelId;
info.FadeTransitions = true;
info.FramesPerSecond = 10;
info.TransitionDuration = 500;
Literal headerContent = new Literal();
headerContent.ID = hostelId + "_Header";
headerContent.Text = hostelName + " More Info ";
Literal content = new Literal();
content.ID = hostelId + "_Content";
content.Text = hostelName + " BOOM ";
infoPane.HeaderContainer.Controls.Add(headerContent);
infoPane.ContentContainer.Controls.Add(content);
info.Panes.Add(infoPane);
cell3.Controls.Add(info);
When I run the page, the contente for the Accordian control displays, but its just text and not the actual accordian. Just wondering if someone can point me in the right direction.
Upvotes: 2
Views: 4915
Reputation: 147401
I'm guessing you also need to add the Accordion
to the ScriptManager
on your page.
scriptManager.Controls.Add(info);
Also, have you tried adding the control in another event handler? It seeems that Init
is the event on which you should dynamically be adding controls, at least according to this Microsoft Support page. (I can't remember where I've done it in my web applications, but Init
would sound right.)
Hope that helps.
Upvotes: 1