本文整理匯總了VB.NET中System.Web.UI.ITemplate接口的典型用法代碼示例。如果您正苦於以下問題:VB.NET ITemplate接口的具體用法?VB.NET ITemplate怎麽用?VB.NET ITemplate使用的例子?那麽, 這裏精選的接口代碼示例或許可以為您提供幫助。
在下文中一共展示了ITemplate接口的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: New
' 導入命名空間
Imports System.Web
Imports System.Web.UI
Namespace TemplateControlSamplesVB
Public Class TemplateItem
Inherits Control
Implements INamingContainer
Private _message As String = Nothing
Public Sub New(Message As String)
_message = message
End Sub
Public Property Message As String
Get
Return _message
End Get
Set
_message = Value
End Set
End Property
End Class
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust"), _
ParseChildren(true)> _
Public Class Template1VB
Inherits Control
Implements INamingContainer
Private _messageTemplate As ITemplate = Nothing
Private _message As String = Nothing
Public Property Message As String
Get
Return _message
End Get
Set
_message = Value
End Set
End Property
<TemplateContainer(GetType(TemplateItem))> _
Public Property MessageTemplate As ITemplate
Get
Return _messageTemplate
End Get
Set
_messageTemplate = Value
End Set
End Property
Protected Overrides Sub CreateChildControls()
' If a template has been specified, use it to create children.
' Otherwise, create a single LiteralControl with the message value.
If Not (MessageTemplate Is Nothing)
Controls.Clear()
Dim I As New TemplateItem(Me.Message)
MessageTemplate.InstantiateIn(I)
Controls.Add(I)
Else
Me.Controls.Add(New LiteralControl(Me.Message))
End If
End Sub
End Class
End Namespace