I was reading a resource that said:
CurrentUICulture must be set at the startup of a application.
For an ASP.NET web page, where do I set this property appropriately?
I was reading a resource that said:
CurrentUICulture must be set at the startup of a application.
For an ASP.NET web page, where do I set this property appropriately?
Web.config:
<globalization culture="en-US" uiCulture="en" requestEncoding="utf-8" responseEncoding="utf-8" />
In a web page, you can set Culture and UICulture in the page directive:
<%@ Page .... Culture="en-US" UICulture="en-US" %>
It doesn't have to be set at application startup.
Update: And as Kristof Claes mentions in a comment, you can set it in code during Page_Init
:
System.Threading.Thread.CurrentThread.CurrentCulture =
new System.Globalization.CultureInfo("en-US");
System.Threading.Thread.CurrentThread.CurrentUICulture =
new System.Globalization.CultureInfo("en-US");
Did you try:
Page.Culture = "your culture";
Page.UICulture = "your culture";
See Page.UICulture Property and Page.Culture Property on MSDN.
I do this, on the page itself
Protected Overrides Sub InitializeCulture()
If Not Me.IsPostBack Then
Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo(var.Sess.lang)
Threading.Thread.CurrentThread.CurrentCulture = Globalization.CultureInfo.CreateSpecificCulture(Threading.Thread.CurrentThread.CurrentUICulture.Name)
End If
MyBase.InitializeCulture()
End Sub