Monday, September 3, 2012

ASP.NET 3 way to Get or Set Culture in ASP.NET

The ASP.NET can set culture for browser to run under a specified culture.
Date display and LocalResource in App_GlobalResources will change by specified culture.
We have 3 way for set culture for this case see below.

In Internet information Service (IIS) > .Net Globalization.

In Web.Config > system.web section > globalization

In CodeBehind should be like this.

        Response.Write(System.Threading.Thread.CurrentThread.CurrentCulture)
        Response.Write("
") Response.Write(DateTime.Now.ToString("dd MMMM yyyy - HH:mm:ss")) Response.Write("

") System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("ja-JP") Response.Write(System.Threading.Thread.CurrentThread.CurrentCulture) Response.Write("
") Response.Write(DateTime.Now.ToString("dd MMMM yyyy- HH:mm:ss")) Response.Write("
")

Pls enjoy ZomDev

No comments:

Post a Comment