Sunday, May 19, 2013

Compare validator in asp.net

Here I describe sample code for compare validator in asp.net.
Syntax :
<asp:CompareValidator ID="cm1" runat="server" Operator="LessThanEqual" Type="Date" ControlToValidate="txt_from_date" ControlToCompare="txt_to_date" ErrorMessage="To date not less than From date" Display="Dynamic" SetFocusOnError="True">
Where
  Controltovalidate : control id to be validate.
Controltocompare: control id which will be compared.
Operator :  operator such as equal, lessthan,Greaterthan etc..
Example:
i use compare validator in c#. there are two textboxes Todate and from date. todate is not less than fromdate. so i use like :
Date from : <asp.textbox id="txt_from_date" runat="server">
Date to: <asp.textbox id="txt_to_date" runat="server">
<asp:CompareValidator ID="cm1" runat="server" Operator="LessThanEqual" Type="Date" ControlToValidate="txt_from_date" ControlToCompare="txt_to_date" ErrorMessage="To date not less than From date" Display="Dynamic" SetFocusOnError="True">

If you are searching life partner. your searching end with kpmarriage.com. now kpmarriage.com offer free matrimonial website which offer free message, free chat, free view contact information. so register here : kpmarriage.com- Free matrimonial website

0 comments:

Post a Comment