Can anyone guide me in the right direction or give an example of How I would accomplish this?
I have this so far but kind of stuck on how to do it programtically if I'm using header and content templates
I have a xmldatasource.. In a nutshell at what point in my code do I need to create a new accordion? does it need to be
in the item_databound handler?
Imports Microsoft.VisualBasic
Public Class AccordionTemplate
Implements System.Web.UI.ITemplate
Dim templateType As String
Sub New(ByVal type As String)
templateType = type
End Sub
Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) _
Implements System.Web.UI.ITemplate.InstantiateIn
Dim ph As New PlaceHolder()
Select Case (templateType)
Case "Header"
Dim myLabel As Label = New Label()
myLabel.Text = "Test"
ph.Controls.Add(myLabel)
Case "Content"
ph.Controls.Add(New LiteralControl("<p>hello</p>"))
End Select
container.Controls.Add(ph)
End Sub
End Class
Partial Class Accordion
Inherits System.Web.UI.Page
Protected Sub AddDetailAccordion(ByVal levels As Integer)
Dim parentAd As New AjaxControlToolkit.Accordion
parentAd.ID = "MyAccordion"
parentAd.HeaderCssClass = "accordionHeader"
parentAd.ContentCssClass = "accordionContent"
parentAd.RequireOpenedPane = "false"
parentAd.FadeTransitions = "True"
parentAd.SelectedIndex = "-1"
parentAd.SuppressHeaderPostbacks = "true"
parentAd.FramesPerSecond = "40"
parentAd.TransitionDuration = "250"
parentAd.HeaderCssClass = "accordionHeader"
parentAd.HeaderSelectedCssClass = "accordionHeaderSelected"
parentAd.ContentCssClass = "accordionContent"
parentAd.DataSourceID = "XmlDataSourceVinylWindows"
parentAd.HeaderTemplate = New AccordionTemplate("Header")
parentAd.ContentTemplate = New AccordionTemplate("Content")
Panel1.Controls.Add(parentAd)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AddDetailAccordion(1)
End Sub
davide128
Member
80 Points
155 Posts
Create databound nested ajax toolkit accordion programatically(In code Behind)
Aug 24, 2010 06:47 PM|LINK
Can anyone guide me in the right direction or give an example of How I would accomplish this?
I have this so far but kind of stuck on how to do it programtically if I'm using header and content templates
I have a xmldatasource.. In a nutshell at what point in my code do I need to create a new accordion? does it need to be
in the item_databound handler?
Imports Microsoft.VisualBasic Public Class AccordionTemplate Implements System.Web.UI.ITemplate Dim templateType As String Sub New(ByVal type As String) templateType = type End Sub Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) _ Implements System.Web.UI.ITemplate.InstantiateIn Dim ph As New PlaceHolder() Select Case (templateType) Case "Header" Dim myLabel As Label = New Label() myLabel.Text = "Test" ph.Controls.Add(myLabel) Case "Content" ph.Controls.Add(New LiteralControl("<p>hello</p>")) End Select container.Controls.Add(ph) End Sub End ClassPartial Class Accordion Inherits System.Web.UI.Page Protected Sub AddDetailAccordion(ByVal levels As Integer) Dim parentAd As New AjaxControlToolkit.Accordion parentAd.ID = "MyAccordion" parentAd.HeaderCssClass = "accordionHeader" parentAd.ContentCssClass = "accordionContent" parentAd.RequireOpenedPane = "false" parentAd.FadeTransitions = "True" parentAd.SelectedIndex = "-1" parentAd.SuppressHeaderPostbacks = "true" parentAd.FramesPerSecond = "40" parentAd.TransitionDuration = "250" parentAd.HeaderCssClass = "accordionHeader" parentAd.HeaderSelectedCssClass = "accordionHeaderSelected" parentAd.ContentCssClass = "accordionContent" parentAd.DataSourceID = "XmlDataSourceVinylWindows" parentAd.HeaderTemplate = New AccordionTemplate("Header") parentAd.ContentTemplate = New AccordionTemplate("Content") Panel1.Controls.Add(parentAd) End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load AddDetailAccordion(1) End Sub