In my Web application I need to show the date in dd/mm/yyyy format to the user. In my application i am showing the date in various forms e.g. In GridView, In dataGrid, In combo, In textBox etc.
actually pretty, I am using hundreds of pages in my web application. Now it is very difficult to change the format of each and every control and line manually.
is there have any way to do this for whole application in one go?
Just place a <pages culture="Auto" /> element in your Web.config (under the system.web element) and each user will get the dates formatted to their own preferences.
If you want all users to get a dd/mm/yyyy format, just write <pages culture="fr-FR" /> for instance...
Hope this helps,
Arnaud
localizationDates formatToString
Microsoft .net Training and Consulting
http://www.dreamdotnet.com/
Marked as answer by Kevin Yu - MSFT on May 14, 2007 08:22 AM
Parser Error Message: Unrecognized attribute 'culture'. Note that attribute names are case-sensitive.
Source Error:
Line 34: <roleManager enabled="true" />
Line 35: <compilation debug="true" strict="false" explicit="true"/>
Line 36: <pages theme="Default" culture="Auto">
Line 37: <namespaces>
Line 38: <clear/>
I put the code on web.config at root.
Am I miss something here ?
Just wondering: if you use a DataFormatString for the date, it won't take into account the culture to display the date, so it won't vary for users with other languages... But that may be what you want...
Best regards,
Arnaud
Microsoft .net Training and Consulting
http://www.dreamdotnet.com/
priyank.kans...
Member
7 Points
98 Posts
Convert Date Format from mm/dd/yyyy to dd/mm/yyyy
May 10, 2007 10:00 AM|LINK
Hi,
In my Web application I need to show the date in dd/mm/yyyy format to the user. In my application i am showing the date in various forms e.g. In GridView, In dataGrid, In combo, In textBox etc.
how will it be possible?
Thanks
Priyank Kansal
niraj_d418
Member
175 Points
42 Posts
Re: Convert Date Format from mm/dd/yyyy to dd/mm/yyyy
May 10, 2007 11:44 AM|LINK
dear,
try this, String.Format("{0:yyyy-MM-dd HH:mm:ss}", Now)
it will return string like "2007-05-01 12:30:01"
set format as per your need.
Niraj sikotara.
<!-- Search before you scramble. --!>
priyank.kans...
Member
7 Points
98 Posts
Re: Convert Date Format from mm/dd/yyyy to dd/mm/yyyy
May 10, 2007 11:58 AM|LINK
actually pretty, I am using hundreds of pages in my web application. Now it is very difficult to change the format of each and every control and line manually.
is there have any way to do this for whole application in one go?
regards
Priyank Kansal
aweil
Member
725 Points
118 Posts
Re: Convert Date Format from mm/dd/yyyy to dd/mm/yyyy
May 11, 2007 05:12 AM|LINK
Hi,
Sure, there's a simpler way to go!
Just place a <pages culture="Auto" /> element in your Web.config (under the system.web element) and each user will get the dates formatted to their own preferences.
If you want all users to get a dd/mm/yyyy format, just write <pages culture="fr-FR" /> for instance...
Hope this helps,
Arnaud
localization Dates format ToString
http://www.dreamdotnet.com/
Helgeduelbec...
Member
18 Points
16 Posts
Re: Convert Date Format from mm/dd/yyyy to dd/mm/yyyy
May 13, 2007 02:36 PM|LINK
Hi,
I've problem too, regarding date format.
Arnaud, I still have an error ;
Parser Error Message: Unrecognized attribute 'culture'. Note that attribute names are case-sensitive.
Source Error:
I put the code on web.config at root.
Am I miss something here ?
Thank you all
aweil
Member
725 Points
118 Posts
Re: Convert Date Format from mm/dd/yyyy to dd/mm/yyyy
May 13, 2007 08:20 PM|LINK
Ooops, I'm sorry...
The right thing to write in the Web.config is:
<system.web> <globalization culture="auto" uiCulture="auto" enableClientBasedCulture="true"/> ...http://www.dreamdotnet.com/
Helgeduelbec...
Member
18 Points
16 Posts
Re: Convert Date Format from mm/dd/yyyy to dd/mm/yyyy
May 15, 2007 02:08 AM|LINK
Yeah,
Thank you a lot ...
And I put addtional line : HtmlEncode = "False"
<asp:BoundField DataField="Start" DataFormatString="{0:dd-MMM-yyyy}"For my gridview to display the right formatdate.
HeaderText="Start"
SortExpression="Start"
HtmlEncode="False" >
<ItemStyle Wrap="False" />
</asp:BoundField> Thanks
aweil
Member
725 Points
118 Posts
Re: Convert Date Format from mm/dd/yyyy to dd/mm/yyyy
May 15, 2007 07:29 AM|LINK
You're welcome, I'm glad I could help!
Just wondering: if you use a DataFormatString for the date, it won't take into account the culture to display the date, so it won't vary for users with other languages... But that may be what you want...
Best regards,
Arnaud
http://www.dreamdotnet.com/