I am writing a bunch of controls for a Toolkit of controls and each control needs to use the various controls like the CollapsiblePanelExtender, RoundedCornerExtender, popup window extender etc. But since I am using the Web Control and inheriting from the Composite control but upon rendering if I try to render the extenders, it makes the panel disappear all together. but if I just add the controls in the CreateChildControls(), they appear but the collapse/expand does not work. Also the Rounded corners doesn't work as well. Not sure what I am doing wrong as rendering the extenders does not work and adding the controls to the updatepanel does nothing.
Any help is appreciated. I've attached the code here:
Imports System Imports System.IO Imports System.Web Imports System.Web.UI
''' ''' IUpdatePanelContainer Interface ''' ''' Public Interface IUpdatePanelContainer Sub RenderUpdatePanel(ByVal writer As HtmlTextWriter) End Interface
''' ''' CustomTemplateControl Class ''' ''' Public Class CustomTemplateControl Inherits Control
Private container As IUpdatePanelContainer
Sub New(ByVal container As IUpdatePanelContainer)
Me.container = container
End Sub
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
container.RenderUpdatePanel(writer)
End Sub
End Class
''' ''' CustomUpdatePanel Class ''' ''' Public Class CustomUpdatePanel Inherits UpdatePanel
Private container As IUpdatePanelContainer
Sub New(ByVal container As IUpdatePanelContainer)
Me.container = container
End Sub
Protected Overrides Function CreateContentTemplateContainer() As System.Web.UI.Control
Return New CustomTemplateControl(container)
End Function
End Class
Composite Control
Public Class ProfileManagement Inherits CompositeControl Implements INamingContainer Implements IUpdatePanelContainer
Region "Overridden Events"
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
MyBase.OnInit(e)
' Create the main grid with the expandable panel and the inner table with the profile rows
CreateGridTable()
' Add the Buttons at the end of the Authentication Control based on the PaymentOption set
CreateButtonControls()
' Add the Back/Next buttons and the powered-by image
CreateFooterControls()
End Sub
Protected Overrides Sub CreateChildControls()
Controls.Clear()
upd = New CustomUpdatePanel(Me)
upd.ContentTemplateContainer.Controls.Add(pnlMain)
upd.ContentTemplateContainer.Controls.Add(pnlButtons)
upd.ContentTemplateContainer.Controls.Add(pnlFooter)
upd.ContentTemplateContainer.Controls.Add(roundedCornetEx)
upd.ContentTemplateContainer.Controls.Add(colPanelExdr)
'pnlMain.Controls.Add(roundedCornetEx)
'pnlMain.Controls.Add(colPanelExdr)
Me.Controls.Add(upd)
'Me.Controls.Add(roundedCornetEx)
'Me.Controls.Add(colPanelExdr)
End Sub
End Region
Region "IUpdatePanelContainer Members"
Public Sub RenderUpdatePanel(ByVal writer As HtmlTextWriter) Implements IUpdatePanelContainer.RenderUpdatePanel
'roundedCornetEx.RenderControl(writer)
'colPanelExdr.RenderControl(writer)
pnlMain.RenderControl(writer)
pnlButtons.RenderControl(writer)
pnlFooter.RenderControl(writer)
End Sub
End Region
Region "Private Methods"
Private Sub CreateGridTable()
Dim tRow As New TableRow()
Dim tCol As New TableCell()
pnlMain = New Panel()
pnlMain.ID = "pnlMain"
pnlMain.Width = Unit.Percentage(100)
tblMain = New Table()
tblMain.Width = Unit.Percentage(100)
pnlMain.Controls.Add(tblMain)
roundedCornetEx = New AjaxControlToolkit.RoundedCornersExtender()
roundedCornetEx.TargetControlID = "pnlMain"
roundedCornetEx.Radius = 6
roundedCornetEx.Corners = AjaxControlToolkit.BoxCorners.All
roundedCornetEx.ClientState = True
tCol.Width = Unit.Percentage(80)
tCol.HorizontalAlign = HorizontalAlign.Left
hlnkbtnHeader = New LinkButton()
hlnkbtnHeader.ID = "hlnkbtnHeader"
hlnkbtnHeader.Text = "Payment Profiles"
lblColPanel = New Label()
lblColPanel.CssClass = "txtlabel"
lblColPanel.ID = "lblColPanel"
lblColPanel.Text = "(Hide Payment Profiles..)"
tCol.BackColor = Drawing.Color.WhiteSmoke
tCol.Controls.Add(hlnkbtnHeader)
tCol.Controls.Add(New LiteralControl(" "))
tCol.Controls.Add(New LiteralControl(" "))
tCol.Controls.Add(lblColPanel)
tRow.Cells.Add(tCol)
tCol = New TableCell()
tCol.HorizontalAlign = HorizontalAlign.Right
tCol.Width = Unit.Percentage(20)
tCol.BackColor = Drawing.Color.WhiteSmoke
imgAscDesc = New Image()
imgAscDesc.ID = "imgAscDesc"
imgAscDesc.ImageUrl = "desc.gif"
tCol.Controls.Add(imgAscDesc)
tRow.Cells.Add(tCol)
tblMain.Rows.Add(tRow)
tRow = New TableRow()
tCol = New TableCell()
tCol.ColumnSpan = 2 : tCol.HorizontalAlign = HorizontalAlign.Left
tCol.Width = Unit.Percentage(100)
tCol.Controls.Add(CreateInnerTable())
tRow.Cells.Add(tCol)
tblMain.Rows.Add(tRow)
' CollapsiblePanel Extender
colPanelExdr = New AjaxControlToolkit.CollapsiblePanelExtender()
colPanelExdr.ID = "cpe" : colPanelExdr.TargetControlID = pnlMain.ClientID
colPanelExdr.CollapsedSize = 0 ' colPanelExdr.ExpandedSize = 300
colPanelExdr.Collapsed = True
colPanelExdr.ExpandControlID = hlnkbtnHeader.ClientID
colPanelExdr.CollapseControlID = hlnkbtnHeader.ClientID
colPanelExdr.AutoCollapse = False : colPanelExdr.AutoExpand = False
colPanelExdr.ScrollContents = True
colPanelExdr.TextLabelID = lblColPanel.ClientID
colPanelExdr.CollapsedText = "(Show Payment Profiles..)" : colPanelExdr.ExpandedText = "(Hide Payment Profiles..)"
colPanelExdr.ImageControlID = imgAscDesc.ClientID
colPanelExdr.ExpandedImage = "styles/style_7/desc.gif" : colPanelExdr.CollapsedImage = "styles/style_7/asc.gif"
colPanelExdr.ExpandDirection = AjaxControlToolkit.CollapsiblePanelExpandDirection.Vertical
colPanelExdr.ClientState = True
End Sub
End Region
End Class