CompareValidator Control in example   

3 522 Question In | Asp.Net
Fri Nov 9, 2018 Megha Gupta

Please any one can explain in detail 

thanks in advance

The CompareValidator control allows you to make comparison to compare data entered in an input control with a constant value or a value in a different control.
It can most commonly be used when you need to confirm password entered by the user at the registration time. The data is always case sensitive. 

<asp:TextBox ID="txtPassword" Text="Hello" runat="server"></asp:TextBox>
<asp:TextBox ID="txtReEnterPassword" Text="Hell" runat="server"></asp:TextBox>

<asp:CompareValidator ID="cvcCompairValidation" runat="server" ValidationGroup="cvc" ControlToCompare="txtPassword" ForeColor="Red" ControlToValidate="txtReEnterPassword" 
ErrorMessage="Password Not Match"></asp:CompareValidator> 

<asp:Button ID="btnCompairValidation" runat="server" ValidationGroup="cvc" Text="Compair Both TextBox Validation" />


If you have more than one form inside the same page : Use ValidationGroup="ConceitCode" what ever you want to name it.

If you don't want to validatde any control : Use CauseValidation="false"

Amit Kumar

22  Fri Nov 9,2018  Solved      

Mic , This has been Solved & updated


26  Sun Dec 2,2018       

Thanks buddy


26  Mon Dec 3,2018       

Subscribe & Get Regular Updates On Your E-mail