<%@ Page Language="VB" %>
<%@ Register TagPrefix="Java2sASP" TagName="LoginForm" src="Control.ascx" %>
<html><body>
<form runat="server">
<Java2sASP:LoginForm id="LoginForm1" runat="server"/>
</form>
<asp:Label id="lblMessage" runat="server" />
</body></html>
File: Control.ascx
<script runat="server">
sub Submit(Sender as Object, e as EventArgs)
if Page.IsValid then
'do something
end if
end sub
sub ValidateThis(Sender as Object, args as _
ServerValidateEventArgs)
if len(args.Value) < 4 then
args.IsValid = false
else
args.IsValid = true
end if
end sub
</script>
<asp:Label id="lblMessage" runat="server" />
<table>
<tr>
<td valign="top">Username:</td>
<td valign="top">
<asp:Textbox id="tbUserName" runat="server"/><br>
<asp:CustomValidator runat="server"
OnServerValidate="ValidateThis"
OnClientValiate="validateLength"
Display="Dynamic"
ControlToValidate="tbUserName"
ErrorMessage="The username must be 4 characters or longer"/>
</td>
</tr>
<tr>
<td valign="top">Password:</td>
<td valign="top">
<asp:Textbox id="tbPassword" runat="server" TextMode="password" />
</td>
</tr>
<tr>
<td align="right">
<ASP:Button id="tbSubmit" runat="server" OnClick="Submit" text="Submit" />
</td>
</tr>
</table>
|