How can i change system culture that affects all pages(programmatically)?
i saw this thread.
but i want to change culture in my Login page with this codes.
protected void btnChangeLanguage(object sender, EventArgs e)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("es");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("es");
}
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fa-IR")
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("fa-IR")
My Culture Changed by top Code.
I checked by this code.
MsgBox("Current Culture is " + CultureInfo.CurrentCulture.EnglishName)
but still our text and labels are english. (i have english resource and persian resource.)
For a list of all cultures, see the documentation for the
CultureInfoclassRegarding your other question, you can save a cookie with the language code as its value, and read it in the overriden
InitializeCultureas follows:Set the cookie with the language code as its value as soon as the user clicks the button:
(Little side note: I’ve appended a
_Clickto the handler’s name, since it may cause a conflict with the button’s name in the definition)Read the cookie as soon as the
InitializeCulturemethod is invoked during the early stages of the page’s lifecycle: