unable to get changed culture value

95 views Asked by At

i am not able to get changed culture value.i have drowdownlist .After changing of dropdown value my culture is going to change.but everytime i am geting english culture value.please let me know how to get value as per culture changed.

below is my code:

protected void ddlclick_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session["CurrentUI"] = "pa-IN";
        Response.Redirect(Request.Url.OriginalString);
    }

protected void Page_Load(object sender, EventArgs e)
    {

        if (Session["CurrentUI"] != null)
        {
            String selectedLanguage = (string)Session["CurrentUI"];
            UICulture = selectedLanguage;
            Culture = selectedLanguage;

            Thread.CurrentThread.CurrentCulture =
                CultureInfo.CreateSpecificCulture(selectedLanguage);
            Thread.CurrentThread.CurrentUICulture = new
                CultureInfo(selectedLanguage);
        }

        base.InitializeCulture();

         if (Thread.CurrentThread.CurrentCulture.ToString() == "pa-IN")
        {
            string ind1 =(string)ResourceDLL.abc.company.company1.Name;


            lblmsg.Text = ind1;
        }
   }
1

There are 1 answers

0
Sain Pradeep On

To change it programmatically you need to override the InitializeCulture() of your web page.

 protected override void InitializeCulture()
    {
      if (Session["CurrentUI"] != null)
        {
            String selectedLanguage = (string)Session["CurrentUI"];
            UICulture = selectedLanguage;
            Culture = selectedLanguage;

            Thread.CurrentThread.CurrentCulture =
                CultureInfo.CreateSpecificCulture(selectedLanguage);
            Thread.CurrentThread.CurrentUICulture = new
                CultureInfo(selectedLanguage);
        }

        base.InitializeCulture();

         if (Thread.CurrentThread.CurrentCulture.ToString() == "pa-IN")
        {
            string ind1 =(string)ResourceDLL.abc.company.company1.Name;


            lblmsg.Text = ind1;
        }
    }