Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Culture

Reply
Thread Tools

Culture

 
 
JezB
Guest
Posts: n/a
 
      12-09-2003
How do I programatically set the culture at session level ?


 
Reply With Quote
 
 
 
 
SSW
Guest
Posts: n/a
 
      12-09-2003
For making culture specific u need to import
Imports System.Globalization
Imports System.Threading

With we get current user culture info.
Request.UserLanguages;

U can set Thread, for UI current culture used by the Resource Manager to
look up culture-specific Thread.
CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(Request.UserLang uages(0))
Thread.CurrentThread.CurrentUICulture = New
CultureInfo(Request.UserLanguages(0))

If u want to set specific then u can use. For eg.
Thread.CurrentThread.CurrentUICulture = new CultureInfo("ja")

Their r many document to culture is availbale on web.

HTH.

Thanks,

sswalia



"JezB" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How do I programatically set the culture at session level ?
>
>



 
Reply With Quote
 
 
 
 
JezB
Guest
Posts: n/a
 
      12-09-2003
The problem I am having is that a change of culture is not "sticking". I
provide a poplist of cultures and allow the user to select culture from a
poplist. In the handler for this poplist I set CurrentCulture and
CurrentUICulture, thus :

private void cCulture_SelectedIndexChanged(object sender, System.EventArgs
e)
{
string newCulture = cCulture.SelectedItem.Value;
Thread.CurrentThread.CurrentCulture = new CultureInfo(newCulture);
Thread.CurrentThread.CurrentUICulture =
Thread.CurrentThread.CurrentCulture;

Debug.WriteLine("Culture switched to "+newCulture);
testCulture();
// loses culture again here
}

and in testCulture() I write out some dates and numbers to check what
culture is being used. When I change the culture using the poplist I get the
output I expect, but if I invoke testCulture from some other handler, eg. a
button handler, the output is in the default English-US again (when I hit
the button AFTER changing the culture poplist).

What am I missing? HOw can I make the change of culture stick not only
within the context of the Page being run, but all other pages run in the
user's session?


"SSW" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> For making culture specific u need to import
> Imports System.Globalization
> Imports System.Threading
>
> With we get current user culture info.
> Request.UserLanguages;
>
> U can set Thread, for UI current culture used by the Resource Manager to
> look up culture-specific Thread.
> CurrentThread.CurrentCulture =
> CultureInfo.CreateSpecificCulture(Request.UserLang uages(0))
> Thread.CurrentThread.CurrentUICulture = New
> CultureInfo(Request.UserLanguages(0))
>
> If u want to set specific then u can use. For eg.
> Thread.CurrentThread.CurrentUICulture = new CultureInfo("ja")
>
> Their r many document to culture is availbale on web.
>
> HTH.
>
> Thanks,
>
> sswalia
>
>
>
> "JezB" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > How do I programatically set the culture at session level ?
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Rob Dob ASP .Net Web Controls 0 11-27-2005 03:57 PM
[MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Rob Dob ASP .Net 0 11-27-2005 03:57 PM
How to change the current thread current culture at run time. Manu ASP .Net 1 07-20-2003 03:27 PM
ASP.NET application wrong culture picked up Aliasgar Pocketwala ASP .Net 2 07-17-2003 02:26 PM
Nasty bug in documentation regarding globalization - wrong Culture Info name for Serbian (Cyrilic) Dejan Vesic ASP .Net 1 07-03-2003 12:32 AM



Advertisments