Wednesday 8 October 2014

Compare Validatior Control in Asp.Net C#

No comments    
categories: ,
COMPARE VALIDATOR


The CompareValidator control compares a value in one control with a fixed value, or, a value in another control.
CompareValidator control compare user inputted value with the another input control value or a constant value. 



                       DEMO


              Html Coding


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table>

        <tr><td>
            <asp:Label ID="Label1" runat="server" Text="Password"></asp:Label>
            </td><td>
                <asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
                <asp:CompareValidator ID="CompareValidator1"
                    runat="server" ControlToCompare="txtConfirmPassword" ControlToValidate="txtPassword"></asp:CompareValidator>
            </td></tr>
        <tr><td>
            <asp:Label ID="Label2" runat="server" Text="Confirm Password"></asp:Label>
            </td><td>
                <asp:TextBox ID="txtConfirmPassword" runat="server"></asp:TextBox>
                <asp:CompareValidator ID="CompareValidator2"
                     runat="server" ControlToCompare="txtPassword"
                    ControlToValidate="txtConfirmPassword" ErrorMessage="Password Not Same"></asp:CompareValidator>
            </td></tr>
        <tr><td colspan ="2">
            <asp:Button ID="Button1" runat="server" Text="Save" />
            </td></tr>

    </table>
    </div>
    </form>
</body>
</html>











         






0 comments:

Post a Comment