Culture

Discussion in 'ASP .Net' started by JezB, Dec 9, 2003.

  1. JezB

    JezB Guest

    How do I programatically set the culture at session level ?
     
    JezB, Dec 9, 2003
    #1
    1. Advertising

  2. JezB

    SSW Guest

    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.UserLanguages(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" <> wrote in message
    news:...
    > How do I programatically set the culture at session level ?
    >
    >
     
    SSW, Dec 9, 2003
    #2
    1. Advertising

  3. JezB

    JezB Guest

    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" <> wrote in message
    news:...
    > 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.UserLanguages(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" <> wrote in message
    > news:...
    > > How do I programatically set the culture at session level ?
    > >
    > >

    >
    >
     
    JezB, Dec 9, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dejan Vesic
    Replies:
    1
    Views:
    697
    Chee Seong Ong
    Jul 3, 2003
  2. Aliasgar Pocketwala

    ASP.NET application wrong culture picked up

    Aliasgar Pocketwala, Jul 17, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    672
    Mario Vargas
    Jul 17, 2003
  3. Manu
    Replies:
    1
    Views:
    6,193
    Natty Gur
    Jul 20, 2003
  4. S. Justin Gengo

    Re: Differences between culture options

    S. Justin Gengo, Aug 8, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,454
    S. Justin Gengo
    Aug 8, 2003
  5. Vidar Petursson

    Re: Javascript: date in culture/language format.

    Vidar Petursson, Aug 15, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    5,560
    Vidar Petursson
    Aug 15, 2003
Loading...

Share This Page