Blogger Widgets
  • Sharing Photos using SignalR
  • TFS Extenstion - allows copy work items between projects
  • Displaying jquery progressbar with ajax call on a modal dialog
  • Managing windows services of a server via a website
  • Exploring technologies available to date. TechCipher is one place that any professional would like to visit, either to get an overview or to have better understanding.

Search This Blog

Wednesday, 7 December 2011

ASP.NET MVC not rendering correct dateformat using CultureInfo

Reading "DateTimeFormat" using cultureinfo is not getting clients date format with the following code :-
CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture(HttpContext.Current.Request.UserLanguages[0]);
DateTimeFormatInfo dtInfo = cultureInfo.DateTimeFormat;
After debugging the code, the dateformat is not honouring globalization ie.. if the client is in US but application is deployed in UK then the format is rendered correctly. So after looking into this article Globalization, Internationalization and Localization in ASP.NET MVC 3, JavaScript and jQuery Part 1 - by Scott HanselmanI have found that the issue is not with the code but a setting in web.config
globalization enableclientbasedculture="true" uiculture="auto" culture="auto"
Now this has solved the issue.

I am sorry to say that there is too much point to the wisecrack that life is extinct on other planets because their scientists were more advanced than ours. ~John F. Kennedy


Copyright © 2013 Template Doctor . Designed by Malith Madushanka - Cool Blogger Tutorials | Code by CBT | Images by by HQ Wallpapers