我拥有的代码(如下)可以工作,除非我将 添加ref="abc"
到TemplateItem
标签中。包含它时,我收到此错误:
属性“TemplateItem”没有名为“ref”的属性
我该如何解决这个问题?
默认.aspx
<%@ Register Src="~/message.ascx" TagName="Message" TagPrefix="uc" %>
<uc:Message ID="msg" runat="server" abc="123" >
<TemplateItem ref="abc">Hi</TemplateItem>
</uc:Message>
消息.ascx
<asp:placeholder runat="server" id="PlaceHolder1" />
消息.ascx.vb
Partial Class message
Inherits System.Web.UI.UserControl
Public Property abc() As String
Sub Page_Init()
If TemplateItem IsNot Nothing Then
TemplateItem.InstantiateIn(PlaceHolder1)
End If
End Sub
Private m_TemplateItem As ITemplate = Nothing
<TemplateContainer(GetType(TemplateItem2))> _
Public Property TemplateItem() As ITemplate
Get
Return m_TemplateItem
End Get
Set(ByVal value As ITemplate)
m_TemplateItem = value
End Set
End Property
Public Class TemplateItem2
Inherits Control
Implements INamingContainer
Public Property ref() As String
End Class
End Class