本文整理汇总了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