<%@ Control language="VB" ClassName="MyControl" %>
<script runat="server">
Dim _labelText As String
Public Property LabelText() as String
Get
Return _labelText
End Get
Set(Byval value as String)
If Not String.IsNullOrEmpty(value) Then
_labelText = Server.HtmlEncode(value)
End If
End Set
End Property
Sub label1_init(Byval sender as Object, _
ByVal e as EventArgs)
label1.Text = LabelText
End Sub
</script>
<asp:label id="label1" runat="server" Text=""
oninit="label1_init" />
<%@ Page language="VB" %>
<%@ Reference Control="MyControl.ascx" %>
<script runat="server">
Sub Page_Load(ByVal sender As Object, _
ByVal e As EventArgs)
Dim ctrl As MyControl = _
CType(Page.LoadControl("MyControl.ascx"), MyControl)
ctrl.LabelText = "Hello World!"
PlaceHolder.Controls.Add(ctrl)
End Sub
</script>
<html>
<body>
<asp:placeholder id="PlaceHolder"
runat="server" />
</body>
</html>