Last post Jan 12, 2010 01:13 PM by b471code3
Jan 12, 2010 06:56 AM|YehonatanB|LINK
I'm using the Accordion control but i have some troubles while combine it with my custom UserControl.
When i'm tring to add my UserControl to the Content property of the AccordionPane, it's not working.
Also, it's doesnt throw any exception. It's just not look like doin what im ask for.
My custom UserControl (named: "MailAddress.ascx") is pretty empty of value. it's just contain "<p>blabla</p>". I'm sure that it's working (added it manually to my webpage and it's working.
The next code is creating the AccordionPane dynamicly:
The first question is that possible to use custom UserControl as a content of AccordionPane?
What could be that problem?
Jan 12, 2010 08:24 AM|b471code3|LINK
I have a FAQ page I create dynamically. There are 2 loops, first one gets a group name and creates a new Accordion control. The second one, inside the first one, gets all the items in the group and displays them as AccordianPanes.
Dim group = From g In db.FaqGroups _
Order By g.Name _
For Each gr In group
Dim gId As Integer = gr.ID
Dim ac As New Accordion
Dim litDivS As New LiteralControl
litDivS.Text = "<br /><div class=faqHeaderDiv>"
Dim litDivE As New LiteralControl
litDivE.Text = "</div>"
Dim litGroup As New LiteralControl
litGroup.Text = gr.Name
ac.ID = "accord" + gr.ID.ToString()
ac.HeaderCssClass = "accordionFaqHeader"
ac.ContentCssClass = "accordionFaqContent"
ac.TransitionDuration = 250
ac.FadeTransitions = True
ac.RequireOpenedPane = False
ac.SelectedIndex = -1
Dim quest = From q In db.Faqs _
Order By q.Question _
Where q.GroupID = gId _
For Each qu In quest
Dim ap As New AccordionPane
ap.EnableViewState = True
ap.ID = qu.ID
Dim litHeader As New LiteralControl
litHeader.ID = "lblHeader" + qu.ID.ToString()
litHeader.Text = qu.Question
Dim litContent As New LiteralControl
litContent.ID = "lblContent" + qu.ID.ToString()
litContent.Text = qu.Answer + "<br /><br />"
Jan 12, 2010 09:06 AM|YehonatanB|LINK
When i'm using the LiteralControl, there are no problem.
But when i'm tring to use more flexable solution (In my case "User Control") - it's not working.
Is that possible to use an UserControl as the content of AccordionPane?
Jan 12, 2010 10:11 AM|b471code3|LINK
Have you tried using the LoadControl() method?
Control uc = LoadControl("~/Location/OfYour/UserControl.ascx")
Then add uc to the controls collection in the content container of the accordian pane.
Jan 12, 2010 11:08 AM|YehonatanB|LINK
That's solve the problem.
Jan 12, 2010 01:13 PM|b471code3|LINK
Great, glad to help. For further clarification, what you did when you created a New instance of MailAddress was just gave your current page access to the MailAddress class not the user interface (ascx). Using the LoadControl() method will give you the
user interface on the page similar to how you register it on your aspx page:
<%@ Register Src="~/controls/Help.ascx" TagName="Help" TagPrefix="HelpUc" %>