Compare Validator Control in asp.net
For Example: Write a program to demonstrate the use of compare validator control.
<html >
<head runat="server">
<title>Aryan Computer(CompareValidator Control)</title>
</head>
<body>
<form id="form2" runat="server">
<div>
</div>
<center>
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="XX-Large"
ForeColor="#CC0066" Text="Aryan Computers, Barshi"></asp:Label>
</center>
<p>
<asp:Label ID="Label2" runat="server" Font-Bold="True"
Text="Use of Compare Validator:"></asp:Label>
</p>
<asp:Label ID="Label3" runat="server" Text="Password:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" style="margin-left: 77px"
TextMode="Password" Width="248px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator"
ForeColor="Red">*</asp:RequiredFieldValidator>
<p>
<asp:Label ID="Label4" runat="server" Text="Re-Enter Password:"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" style="margin-left: 14px"
TextMode="Password" Width="248px"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="TextBox1" ControlToValidate="TextBox2"
ErrorMessage="Password does not match........."
ForeColor="Red"></asp:CompareValidator>
</p>
<asp:Button ID="Button1" runat="server" Font-Bold="True" Height="31px"
Text="Save" Width="87px" />
</form>
</body>
</html>
Output:
Comments
Post a Comment