.NET Framework Pickup (4) ItemPlater, TemplateContainerattribute
Directory: 1.Itemplater interface 2.ItemplateContainerattribute class
IIIMPLATE interface
When declared in the .aspx file, the method of defining the ASP.NET server control to define the method of implementing the ASP.NET server control when using the control with the inner template. Public interface Itemplate This interface is used to customize server controls, but from these server controls, ASP.NET is always responsible for implementing the interface.
This method does not need to be implemented when there is only one public method Sub Instantiatein (ByVal Container AS Control) Container:
Public Sub InstantiateIn (container As Control) Implements ITemplate.InstantiateIn Dim l As New Literal () AddHandler l.DataBinding, AddressOf Me.BindData container.Controls.Add (l) End Sub 'InstantiateIn
'------------------------------------- -----------------------------------------------
2.ItemplateContainerattribute class
Declare the type of InamingContainer that will contain templates after creating. System.Object System.attribute System.Web.ui.TemplateContainerattribute
'********************************************************** ***************************************************
'File Name: TemplateContainerattribute.cs.
Imports SystemImports System.Webimports System.Web.ui.WebControlsimports System.Collections System.collections System
Namespace CustomTrols
Private _firstTemplate As ITemplate Private [_text] As [String] = Nothing Private _myTemplateContainer As Control
Private _parent As VB_TemplatedFirstControl Public Sub New (parent As VB_TemplatedFirstControl) Me._parent = parent End Sub 'New Public ReadOnly Property [Text] () As [String] Get Return _parent.Text End Get End Property Public ReadOnly Property DateTime () As [ String] get return _parent.datetime End Get End Property
End class' VB_FirstTemplateContainer
End Namespace 'CustomControls
'********************************************************** ****************************************