hi Phillip,
because for example, in a chinese cybercafe I want a american user to
login
in our system and be able to choose his preferred language just once and
then this selection to be applied in all the other pages.
I tried your suggestion but, I do not want to put in every single page
code
like Page.Culture = "en-us".
-E
Why not use the user's browser settings upon each postback instead?
You
can
set Culture="auto" UICulture="auto" on the page directive, e.g.:
http://www.webswapp.com/CodeSamples/aspnet20/AutoCulture.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
:
hi,
I am saving the user selected culture in a session variable so I can
apply
it back to all pages when refreshed and then load the proper .resx
values.
For that I am using global.asax, Application_AcquireRequestState,
because
every page load will execute this method.
Even thou it works, very often I get en exception telling that the
session
can not be retrieved in this context.
What's the best place to actually place this verification in order to
be
reflected in every page of my application?
here the global.asax code
public void Application_AcquireRequestState(object sender, EventArgs
e)
{
if ( Session["myculture"] != null )
{
string currentCulture = (string)Session["myculture"];
if (String.Compare(currentCulture,
System.Threading.Thread.CurrentThread.CurrentCulture.ToString(),
StringComparison.OrdinalIgnoreCase) != 0)
{
try
{
System.Threading.Thread.CurrentThread.CurrentCulture
=
System.Globalization.CultureInfo.CreateSpecificCulture(currentCulture);
}
catch
{
System.Threading.Thread.CurrentThread.CurrentCulture
=
new System.Globalization.CultureInfo("en-us");
}
System.Threading.Thread.CurrentThread.CurrentUICulture
=
System.Threading.Thread.CurrentThread.CurrentCulture;
}
}
}