Click here to Skip to main content
15,868,039 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
First here is my code, I have 2 CalendarExtender

<asp:TextBox ID="date_from" runat="server" TextMode="DateTime" Width="80px"></asp:TextBox><asp:ImageButton runat="Server" ID="ImageButton1" ImageUrl="~/images/ico_calendar.gif" AlternateText="Click here to display calendar" />
<cc1:CalendarExtender ID="CalendarExtender1"  runat="server" TargetControlID="date_from" PopupButtonID="ImageButton1" Format="dd/MM/yyyy" TodaysDateFormat="dd/MM/yyyy"></cc1:CalendarExtender>


<asp:TextBox ID="date_to" runat="server" TextMode="DateTime" Width="80px"></asp:TextBox>
<asp:ImageButton runat="Server" ID="ImageButton2" ImageUrl="~/images/ico_calendar.gif" AlternateText="Click here to display calendar" />
<cc1:CalendarExtender ID="CalendarExtender2"  runat="server" TargetControlID="date_to" PopupButtonID="ImageButton2" Format="dd/MM/yyyy" TodaysDateFormat="dd/MM/yyyy"></cc1:CalendarExtender>


And the CompareValidator:
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="From Date must be earlier than To Date" ControlToCompare="date_from" ControlToValidate="date_to" type="Date" Operator="GreaterThanEqual" display="Dynamic" enableclientscript="true" cultureinvariantvalues="true" ForeColor="red"></asp:CompareValidator>


The Problem is I want the format to be dd/MM/yyyy. When I choose this date range: 03/09/2013 - 02/11/2013 it is triggering the error "Date must be earlier than To Date".

ANy idea how to make the CompareValidator format dd/MM/yyyy.
Posted

1 solution

Here is the Good link which explains same issue where you're having.Check this.

How to use compare validator with dd/MM/yyyy format of date

Another Link : SOF


I hope this will help to you.
 
Share this answer
 
v2
Comments
[no name] 2-Nov-13 3:14am    
Culture="en-GB" Worked for me.
Sampath Lokuge 2-Nov-13 3:17am    
Glad to hear that it helped!.If this is the solution,You can accept it as a solution.It'll help for the user who'll have the same issue in future.
[no name] 2-Nov-13 3:20am    
The Accept button is not appearing ????
Sampath Lokuge 2-Nov-13 3:25am    
Ahh..Try by closing the browser and come again.May be worked.Otherwise no problem :)
[no name] 2-Nov-13 3:28am    
Didn't work. I can only vote you 5.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900