Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
All-Star
95413 Points
14106 Posts
Apr 28, 2012 10:11 AM|LINK
its working fine in C# - all your code working good...
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { } protected void Validate(object source, ServerValidateEventArgs args) { int num = Int32.Parse(args.Value); args.IsValid = ((num % 2) == 0); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <!--Invalid if < 100--> Compare: <asp:TextBox id="txtCompare" runat="server" /> <asp:CompareValidator ID="CompareValidator1" ControlToValidate="txtCompare" Display="Dynamic" Operator="GreaterThanEqual" ValueToCompare="100" Text="*" ErrorMessage="Comparison not valid (Value < 100)!" runat="server"></asp:CompareValidator> <br /> <!--Validation Summary displays only CompareValidator ErrorMessage if both (CompareValidator, CustomValidator) are invalid--> <asp:ValidationSummary ID="ValidationSummary" runat="server" CssClass="ValidationSummary" DisplayMode="List" HeaderText="Bitte überprüfen Sie folgende Eingabe/-n:" /> <br /> <!--Invalid if not odd value--> Custom: <asp:TextBox id="txtCustom" runat="server" /> <asp:CustomValidator id="CustomValidator1" ControlToValidate="txtCustom" OnServerValidate="Validate" Display="Dynamic" ErrorMessage="Custoam not valid (Not an even number)!" runat="server" Text="*" /> <br /> <!--Submit Button--> <asp:Button id="Button1" Text="Validate" runat="server"/> </div> </form> </body> </html>
ramiramilu
All-Star
95413 Points
14106 Posts
Re: CompareValidator and CustomValidator in one Form
Apr 28, 2012 10:11 AM|LINK
its working fine in C# - all your code working good...
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { } protected void Validate(object source, ServerValidateEventArgs args) { int num = Int32.Parse(args.Value); args.IsValid = ((num % 2) == 0); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <!--Invalid if < 100--> Compare: <asp:TextBox id="txtCompare" runat="server" /> <asp:CompareValidator ID="CompareValidator1" ControlToValidate="txtCompare" Display="Dynamic" Operator="GreaterThanEqual" ValueToCompare="100" Text="*" ErrorMessage="Comparison not valid (Value < 100)!" runat="server"></asp:CompareValidator> <br /> <!--Validation Summary displays only CompareValidator ErrorMessage if both (CompareValidator, CustomValidator) are invalid--> <asp:ValidationSummary ID="ValidationSummary" runat="server" CssClass="ValidationSummary" DisplayMode="List" HeaderText="Bitte überprüfen Sie folgende Eingabe/-n:" /> <br /> <!--Invalid if not odd value--> Custom: <asp:TextBox id="txtCustom" runat="server" /> <asp:CustomValidator id="CustomValidator1" ControlToValidate="txtCustom" OnServerValidate="Validate" Display="Dynamic" ErrorMessage="Custoam not valid (Not an even number)!" runat="server" Text="*" /> <br /> <!--Submit Button--> <asp:Button id="Button1" Text="Validate" runat="server"/> </div> </form> </body> </html>JumpStart