Sponsored Ad

Wednesday, June 16, 2010

How to Compaire/Validate Two Double Values in ASP.NET | CompareValidator

Easy date copaire validator is available in ASP.NET 2.0 and later versions. You just need to select type as date in CompareValidator and give name of both textboxes which contains the date.

It can compaire the date between different date formats also. Like you can see example in these two figures.

12/11/2010 and 12/11/09 are different while 12/11/2010 and 12/11/10 are same.

 

How to Compaire/Validate Two Double Values in ASP.NET | CompareValidator

How to Compaire/Validate Two Double Values in ASP.NET | CompareValidator

 

 

How to Compaire/Validate Two Double Values 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 Date Values</h4>
       Date Value 1:
        <asp:TextBox ID="txtDate1" runat="server" />
        <br />
        <br />
        Date Value 2:
        <asp:TextBox ID="txtDate2" runat="server" />
        <br />
        <br />
        <br />
        <asp:Button ID="Button1" Text="Validate" runat="server" />
        <br />
        <br />   
        <asp:CompareValidator ID="compair_Date_values"  ControlToValidate="txtDate1" ControlToCompare="txtDate2"
            ForeColor="red" Type="Date"  Text="Please enter same Date values in both textboxes."
            runat="server" />
    </form>
</body>
</html>

0 comments:

Post a Comment

Sponsored Ad

More Related Articles

Website Update

Followers