Dec 24, 2010, 4:50 PM
Dynamic HTML Content in Accordion Control
I'm trying to load dynamic content to an accordion control. However, i've been having issues. I've tried different variations of the code below and I can't seem to dynamically inject html.
Here's my accordionPanel
At the top of the page, i have the following code that should be triggered from the DirectEvents.
Here's my accordionPanel
<ext:Panel ID="mpAccordionPanel" Title="What's Happening" runat="server">
<Items>
<ext:AccordionLayout ID="AccordionLayout1" runat="server" Animate="true">
<Items>
<ext:Panel ID="accEventsPanel" runat="server" Border="false" Title="Events" >
<Items></Items>
<DirectEvents>
<BeforeRender OnEvent="LoadCalendarEvents"></BeforeRender>
</DirectEvents>
</ext:Panel>
<ext:Panel ID="Panel2" runat="server" Border="false" Collapsed="true" Title="Item 2">
<Items>
</Items>
</ext:Panel>
<ext:Panel ID="Panel3" runat="server" Border="false" Collapsed="true" Title="Item 2">
<Items>
</Items>
</ext:Panel>
</Items>
</ext:AccordionLayout>
</Items>
</ext:Panel>
At the top of the page, i have the following code that should be triggered from the DirectEvents.
<script runat="server">
protected void LoadCalendarEvents()
{
string content = "";
var events = (Session["GroupMembership"] as GroupMembership).UpcomingEvents.ToList();
if (events.Count > 0)
{
foreach (var evnt in events)
{
content += "<div style='padding:5px 5px 5px 5px; width:95%;'>" +
"<table><tr><td><img alt='event' src='../../Content/img/icon-calendar.gif' /></td>" +
"<td style='padding-left:5px;'><span style='font-weight:bold'>" + evnt.title + "</span> - <span style='font-size:smaller'>" + evnt.start_time + "</span></td>" +
"</tr></table></div>";
}
}
else
{
content += "<div style='padding:0px 5px 5px 5px; width:95%'> - No upcoming events.</div>";
}
this.accEventsPanel.ContentContainer.InnerHtml = content;
this.accEventsPanel.UpdateContent();
}
</script>
So basically, how do I load content inside of an accordion panel. Does it need to be in an <item> tag?