valid!";
}
else {
lblOutput.Text = "Page is not valid! :-(";
}
}
bool ServerValidate (object source, string value) {
int num = Int32.FromString(value);
if (num%2 == 0)
return true;
else
return false;
}
</script>
</head>
<body>
<h3><font face="Verdana">CustomValidator Example</font></h3>
<form runat="server">
<asp:Label id=lblOutput runat="server"
Text="Enter an even number:"
Font-Name="Verdana"
Font-Size="10pt" /><br>
<p>
<asp:TextBox id=Text1 runat="server" />
<asp:CustomValidator id="CustomValidator1" runat="server"
ControlToValidate="Text1"
OnServerValidationFunction="ServerValidate"
Display="Static"
Font-Name="verdana" Font-Size="10pt">
Not an even number!
</asp:CustomValidator>
<p>
<asp:Button text="Validate" onclick="ValidateBtn_OnClick" runat="server" />
</form>
</body>
</html>
上一页 [1] [2]