Jump to content

viewstate of custom template control


siri

Recommended Posts

i am creating a custom template control. But the problem is that I am not able to maintain the viewstate of the custom template control.How do i maintain the viewstate of the template items.Here is the code snippet:**********************************************Imports SystemImports System.WebImports System.Web.UINamespace myControlsPublic Class TemplateItemInherits ControlImplements INamingContainer Private _dataItem As String Public Sub New( DataItem As String ) _dataItem = DataItem End Sub Public Property DataItem As String Get Return _dataItem End Get Set _dataItem = Value End Set End PropertyEnd Class<ParseChildren(true)> Public Class SimpleTemplateInherits ControlImplements INamingContainer Private _itemTemplate As ITemplate Private _text As String Public Property Text As String Get Return _text End Get Set _text = Value End Set End Property <TemplateContainer(GetType(TemplateItem))> _ Public Property ItemTemplate As ITemplate Get Return _itemTemplate End Get Set _itemTemplate = Value End Set End Property Public Overrides Sub DataBind() EnsureChildControls() MyBase.DataBind() End Sub Protected Overrides Sub CreateChildControls() Dim objTemplateItem As TemplateItem Controls.Clear() objTemplateItem = New TemplateItem( Me.Text ) ItemTemplate.InstantiateIn( objTemplateItem ) Controls.Add( objTemplateItem ) End SubEnd ClassEnd Namespace********************************************************

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...