File: index.aspx
<%@ Page Language="VB" %>
<%@ Register TagPrefix="Java2sASP" TagName="LoginForm" src="Control.ascx" %>
<script runat="server">
sub Page_Load(Sender as Object, e as EventArgs)
lblMessage.Text = "Properties of the user control: " & _
"<br>id: " & LoginForm1.id & "<br>" & _
"BackColor: " & LoginForm1.BackColor & "<br>" & _
"Username: " & LoginForm1.Username & "<br>" & _
"Password: " & LoginForm1.Password
end sub
</script>
<html><body>
<form runat="server">
<Java2sASP:LoginForm id="LoginForm1" runat="server"
Password="MyPassword"
Username="Chris"
BackColor="Beige" />
</form>
<asp:Label id="lblMessage" runat="server" />
</body></html>
File: Control.ascx
<script language="VB" runat="server">
public BackColor as String = "White"
public property UserName as string
Get
UserName = User.Text
End Get
Set
User.Text = value
End Set
end property
public property Password as string
Get
Password = Pass.Text
End Get
Set
Pass.Text = value
End Set
end property
public sub Submit(obj as object, e as eventargs)
lblMessage.Text = "Username: <b>" & User.Text & _
"</b><br>" & "Password: <b>" & Pass.Text & "</b>"
end sub
</script>
<table style="background-color:white;font: 10pt verdana;border-width:1;border-style:solid;border-color:black;"
cellspacing=15>
<tr>
<td><b>Login: </b></td>
<td><ASP:TextBox id="User" runat="server"/></td>
</tr>
<tr>
<td><b>Password: </b></td>
<td><ASP:TextBox id="Pass" TextMode="Password"
runat="server"/></td>
</tr>
<tr>
<td></td>
<td><ASP:Button Text="Submit" runat="server"
OnClick="Submit" /></td>
</tr>
</table>
<ASP:Label id="lblMessage" runat="server"/>
|