Click here to Skip to main content
13,092,725 members (72,276 online)
Rate this:
Please Sign up or sign in to vote.
See more: , +
<asp:TextBox ID="txt_dateofjoin" runat="server" />
<cc1:CalendarExtender ID="cal2" runat="server" TargetControlID="txt_dateofjoin" Format="dd-MM-yyyy" TodaysDateFormat="dd-MM-yyyy"></cc1:CalendarExtender>
<asp:TextBox ID="txt_confirmationdate" runat="server" />
<cc1:CalendarExtender ID="cal" runat="server" Format="dd-MM-yyyy" TargetControlID="txt_confirmationdate" TodaysDateFormat="dd-MM-yyyy">
<asp:CompareValidator ID="cmpDates" runat="server" ControlToCompare="txt_dateofjoin" ControlToValidate="txt_confirmationdate" Operator="GreaterThan" Type="Date" SetFocusOnError="true" Display="Dynamic" Text="Confirm Date must be greater than Joining Date" />

when I change the Format of CalendarExtender to MM-dd-yyyy then it works fine but in dd-MM-yyyy compare validator consider date to month. Now how I can validate this two date in dd-MM-yyyy format.
Posted 19-Aug-12 18:47pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try setting the property CultureInvariantValues="true" in your CompareValidator .

Dinesh Ambaliya 20-Aug-12 1:35am
it's not work!
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Rewrite your tag for calender extender in following way its solved your problem...

<cc1:CalendarExtender ID="cal2" runat="server" TargetControlID="txt_dateofjoin"
Format="dd/MM/yyyy" TodaysDateFormat="dd/MM/yyyy"></cc1:CalendarExtender>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 20 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100