Here i have explained how to use CompareValidator control in Asp.Net.

CompareValidator
The CompareValidator control is used to compare the one value to another value.

HTML Markup

<asp:TextBox ID="txtbox1" placeholder="Enter password" runat="server"></asp:TextBox>
<asp:TextBox ID="txtbox2" placeholder="Confirm password" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" ControlToCompare="txtbox1" ControlToValidate="txtbox2" Display="Dynamic" ErrorMessage="Password is not matching" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Submit" />

Screenshot

Add Comments