0

我无法获得更改的文化值。我有下拉列表。更改下拉值后,我的文化将会改变。但是每次我获得英语文化值时。请让我知道如何根据文化的变化获得价值。

下面是我的代码:

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;
        }
   }
4

1 回答 1

0

要以编程方式更改它,您需要覆盖网页的 InitializeCulture()。

 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;
        }
    }
于 2013-09-12T06:59:44.677 回答