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>