asp:CustomValidator validation (VB.net)
<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<script runat=server>
Sub ServerValidation9 (source As object, E As ServerValidateEventArgs)
If E.Value mod 9 = 0 Then
E.IsValid = True
Else
E.IsValid = False
End If
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>CustomValidator Control Sample Page</TITLE>
</HEAD>
<BODY >
<form runat="server">
<Font Face="Tahoma">
<BR><BR>
<asp:Label
id="lblMessage"
runat="server"
Font-Bold="True"
Text="Enter a multiple of 9"
/>
<asp:TextBox
id="txt9"
Columns="25"
MaxLength="30"
runat=server
/>
<asp:CustomValidator
id="custom9"
ControlToValidate="txt9"
OnServerValidate="ServerValidation9"
Display="Dynamic"
Font-Name="Verdana"
Font-Bold="True"
Font-Size="10pt"
runat="server">
<BR>You must enter a number that is divisible by 9!
</asp:CustomValidator>
<BR><BR>
<asp:button
id="butOK"
text="OK"
Type="Submit"
runat="server"
/>
</Font>
</Form>
</BODY>
</HTML>
Related examples in the same category