Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I set CurrentUICulture in an ASP.NET web page?

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?

like image 921
Ricky Avatar asked Jan 26 '26 20:01

Ricky


2 Answers

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");
like image 109
Ronald Wildenberg Avatar answered Jan 29 '26 10:01

Ronald Wildenberg


Web.config:

<globalization culture="en-US" uiCulture="en" requestEncoding="utf-8" responseEncoding="utf-8" />
like image 36
bang Avatar answered Jan 29 '26 12:01

bang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!