我无法改变文化价值。我有下拉列表。更改下拉值后,我的文化将会改变。但每次我都在考虑英国文化的价值。请让我知道如何根据文化变化获得价值
下面是我的代码:
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;
}
}
答案 0 :(得分: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;
}
}