Sponsored Ad

Saturday, June 19, 2010

How to Compaire/Validate TextBox and DropDownList Values at client side in ASP.NET | CompareValidator

You can compaire a textbox and a Dropdownlist select value using asp.net comparevalidotor. Just give the name of both controls as given below.

 

How to Compaire/Validate TextBox and DropDownList Values at client side in ASP.NET | CompareValidator

How to Compaire/Validate TextBox and DropDownList Values at client side in ASP.NET | CompareValidator

 

How to Compaire/Validate TextBox and DropDownList Values at client side in ASP.NET | CompareValidator Example:

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<body>
    <form id="Form1" runat="server">
        <h4>
            Compare Two Password Values</h4>
        Textbox Value :
        <asp:TextBox ID="txtValues" runat="server" />
        <br />
        <br />
        Select Dropdown Value:
        <asp:DropDownList ID="DropDownList1" runat="server">
            <asp:ListItem>IndiHub.com</asp:ListItem>
            <asp:ListItem>SoftwareTestingNet.com</asp:ListItem>
        </asp:DropDownList>
        <br />
        <br />
        <asp:Button ID="Button1" Text="Validate" runat="server" />
        <br />
        <br />
        <asp:CompareValidator ID="compair_values" ControlToValidate="txtValues"
            ControlToCompare="DropDownList1" ForeColor="red" Type="string" Text="Please enter same value in textbox as selected in dropdown list."
            Operator="equal" runat="server" />
    </form>
</body>
</html>

No comments:

Post a Comment

Sponsored Ad

Development Updates