I would like to format dates etc in the format that the user browsing the
page would prefer according to his language setting. The DateTimeFormatInfo
class provides all the information I need, but how do I get an instance of
it (or something else that has the info)?
Using DateTimeFormatInfo.Current doesn't work. It gives me the server
settings.
Using HttpRequest.UserLanguages to create a culture doesn't work either. The
language I get from that collection doesn't contain any country/region code
so I get a neutral culture that doesn't have any DataTimeFormatInfo
Is there a way to get the prefered date and time settings for the user that
requested the page?
/claes 4 1991
Hi,
Thank you for posting!
ASP.NET 2.0 has a new feature called 'Auto-Culture Handling': it maps
Accept-Language headers to CultureInfo objects and attaches them to the
current thread. Auto-Culture handling can be enabled for individual pages
by including 'Culture="auto" UICulture="auto"' attributes in the @ Page
directive. It can be enabled site-wide by including a <globalization
culture="auto" uiCulture="auto"/> element in web.config.
Since DataTime's format functions such as ToShortDateString() automatically
uses formatting information derived from the current culture, so for your
requirement, I think simply call these functions without specifying a
DateTimeFormatInfo would be suffice.
If there's anything unclear, please feel free to post here.
Regards,
Walter Wang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Ok, sounds cool. I'll try that
Any way to get hold of this "auto-culture" from code? I would like to get
some info from the corresponding DateTimeFormatInfo, such as the
FirstDayOfWeek property and DayNames collection
/claes
"Walter Wang [MSFT]" <wa****@online.microsoft.com> wrote in message
news:8R**************@TK2MSFTNGXA01.phx.gbl... Hi,
Thank you for posting!
ASP.NET 2.0 has a new feature called 'Auto-Culture Handling': it maps Accept-Language headers to CultureInfo objects and attaches them to the current thread. Auto-Culture handling can be enabled for individual pages by including 'Culture="auto" UICulture="auto"' attributes in the @ Page directive. It can be enabled site-wide by including a <globalization culture="auto" uiCulture="auto"/> element in web.config.
Since DataTime's format functions such as ToShortDateString() automatically uses formatting information derived from the current culture, so for your requirement, I think simply call these functions without specifying a DateTimeFormatInfo would be suffice.
If there's anything unclear, please feel free to post here.
Regards, Walter Wang Microsoft Online Community Support
================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Never mind. I see that I actually get the localized DateTimeFormatInfo using
DateTimeFormatInfo.Current
Thank you. Works perfect now
/claes
"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:OR**************@TK2MSFTNGP02.phx.gbl... Ok, sounds cool. I'll try that Any way to get hold of this "auto-culture" from code? I would like to get some info from the corresponding DateTimeFormatInfo, such as the FirstDayOfWeek property and DayNames collection
/claes
"Walter Wang [MSFT]" <wa****@online.microsoft.com> wrote in message news:8R**************@TK2MSFTNGXA01.phx.gbl... Hi,
Thank you for posting!
ASP.NET 2.0 has a new feature called 'Auto-Culture Handling': it maps Accept-Language headers to CultureInfo objects and attaches them to the current thread. Auto-Culture handling can be enabled for individual pages by including 'Culture="auto" UICulture="auto"' attributes in the @ Page directive. It can be enabled site-wide by including a <globalization culture="auto" uiCulture="auto"/> element in web.config.
Since DataTime's format functions such as ToShortDateString() automatically uses formatting information derived from the current culture, so for your requirement, I think simply call these functions without specifying a DateTimeFormatInfo would be suffice.
If there's anything unclear, please feel free to post here.
Regards, Walter Wang Microsoft Online Community Support
================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
You are welcome.
Have a nice day!
Regards,
Walter Wang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Fotios |
last post by:
Hi guys,
I have put together a flexible client-side user agent detector (written in
js). I thought that some of you may find it useful. Code is here:
http://fotios.cc/software/ua_detect.htm
...
|
by: zlst |
last post by:
Many technological innovations rely upon User Interface Design to elevate
their technical complexity to a usable product. Technology alone may not win
user acceptance and subsequent marketability....
|
by: martin |
last post by:
Hi,
I am a web page and a web user control. My web user control is placed in my
web page using the following directive
<%@ Register TagPrefix="uc1" TagName="Header"...
|
by: Shourie |
last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle.
1) MainPage_load
2) User control1_Load
user clicks a...
|
by: jsale |
last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app
i have made is running on IIS v6 and consists of a number of pages that allow
the user to read information from the...
|
by: tony |
last post by:
Hello!
This is a rather long mail but it's a very interesting one.
I hope you read it. I have tried several times to get an answer to this mail
but I have
not get any answer saying something...
|
by: rn5a |
last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with
the IDs 'txt1' & 'txt2' respectively. To use this user control in an
ASPX page, the following Register directive will be...
|
by: Carlettus |
last post by:
Dear All,
sorry but I'm not sure if this is the right place to post my problem.
I was using the following asp code to create users in Active Directory.
Suddenly, and I don't know the reason, users...
|
by: rbukkara |
last post by:
Hi,
I have got the following error while trying to add a user in the LDAP Directory.
javax.naming.NameNotFoundException: ; remaining name 'uid=vassila,ou=People,dc=cs,dc=uno,dc=edu'
I have...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |