Date in textboxes changing format

Posted by AWinters on Stack Overflow See other posts from Stack Overflow or by AWinters
Published on 2010-06-11T16:25:58Z Indexed on 2010/06/11 16:42 UTC
Read the original article Hit count: 269

Filed under:
|
|

I have an application (asp.net 3.5) that support 4 different languages. Along with other cultural changes, the date formats must match the current culture on out reporting pages.

We set the date formats of each of the textboxes like:

string date = DateTime.Today.ToString("d"); //returns the date portion only

textbox1.Text = date;
textbox2.Text = date;

etc...

When the user selects Spanish or British English the format should be dd/mm/yyyy. However, then I navigate to the page it displays in mm/dd/yyyy. After a postback it then displays dd/mm/yyyy. After another postback it switches to the mm/dd/yyyy format and on and on.

I have debugged through this and I see that the culture is correct for the application and the date formats are returned to me correctly, yet when it displays, it displays incorrectly.

Has anyone ever seen this or know what is happening?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about culture