properties.ascx
<script language="VB" runat="server">
Public Color As String = "black"
Public Text As String = "This is a user control... really!"
</script>
<p>
<font color="<%= Color %>">
<%= Text %>
</font>
</p>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
UserCtrl1.Color = "green"
UserCtrl1.Text = "This control's properties were " _
& "set programmatically!"
End Sub
</script>
<html>
<head>
<title>ASP.NET User Control Sample - Properties</title>
</head>
<body bgcolor="#FFFFFF">
events.ascx
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim strInitialText As String = "Please Enter a Name!"
If Page.IsPostBack Then
If txtName.Text = strInitialText
txtName.Text = ""
End If
Else
txtName.Text = strInitialText
End If
End Sub
Public Property Name As String
Get
Return txtName.Text
End Get
Set
txtName.Text = Value
End Set
End Property
</script>
Name: <asp:textbox id="txtName" runat="server" />
<asp:RequiredFieldValidator ControlToValidate="txtName"
id="valtxtName" Display="Dynamic" runat=server>
Please Enter a Name!
</asp:RequiredFieldValidator>