Click here to Skip to main content
15,888,024 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear developers,

When developing an web site using asp.net 4.0 works fine. But After deploying it in a windows server 2003. It shows all page, there is no problem.

But when saving data from any page which contains ajax date time extender gives "DateTime was not recognized in correct Format" error.

I tried to use DateTime.ParseExtract function using CultureInfo. But Still i could not handle it. Then I tried to use DateTime.Convert, but still gives error.

Please help.
Posted
Comments
Sandeep Mewara 23-Apr-11 1:43am    
Sharing a little code would help.

For now, it sounds like dateformat an issue. May be the server regional settings or the way you are using/storing the datetime.
Anil_Mathew 23-Apr-11 1:45am    
Does the development machine and the deployed server has different time zones?
Angsuman Chakraborty 23-Apr-11 1:49am    
no. its United States. Date Format is dd/MM/yyyy
testsetsdsdfs 30-Nov-12 1:37am    
How asp.net datetime conversion are dependent on time zones..?

1 solution

Put your Code here or

try
Convert.ToDateTime(txtDate.Text);


And in Source you can try the following,-

<cc1:calendarextender id="CalendarExtender2" runat="server" targetcontrolid="txtPeriod" xmlns:cc1="#unknown">
                                                            Format="dd MMM yyyy">
                                                        </cc1:calendarextender>
                                                        <regularexpressionvalidator id="RVal" runat="server" controltovalidate="txtPeriod">
                                                            ErrorMessage="Invalid Format" ValidationExpression="^((31(?!\ (Feb(ruary)?|Apr(il)?|June?|(Sep(?=\b|t)t?|Nov)(ember)?)))|((30|29)(?!\ Feb(ruary)?))|(29(?=\ Feb(ruary)?\ (((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1\d|2[0-8])\ (Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\b|t)t?|Nov|Dec)(ember)?)\ ((1[6-9]|[2-9]\d)\d{2})$"
                                                            ValidationGroup="Grp"></regularexpressionvalidator>
 
Share this answer
 
Comments
Angsuman Chakraborty 23-Apr-11 4:20am    
Its not ajax related issue. Its the Convert.datetime function that needs to be handeled

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