Code Listing: Custom Validator
%@ Page Language="C#" %
script runat="server"
void valComments_ServerValidateObject source, ServerValidateEventArgs args)
{
if (args.Value.Length > 10)
args.IsValid = false;
else
args.IsValid = true;
}
/script
head id="Head1" runat="server"
title Show CustomValidator /title
head body
form id="form1" runat="server"
div
asp:label id="lblComments" text="Comments:" associatedcontrolid="txtComments" runat="server"
asp: TextBox id="txtComments" TextMode="MultiLine"
Columns="30" Rows="5" Runat="server"
asp:CustomValidator id="valComments" ControlToValidate="txtComments"
Text="(Comments must be less than 10 characters)" OnServerValidate="valComments_ServerValidate" Runat="server"
asp:button id="btnSubmit" text="Submit" runat="server"
/div
/form
/body
/html
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment