0
我的頁面不會更改語言可能有人看看我的代碼,並告訴我什麼即時做錯了它總是轉到默認的語言在這裏頁面不會改變語言
public partial class ChangeLanguage : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
SortedDictionary<string, string> objDic = new SortedDictionary<string, string>();
foreach (CultureInfo ObjectCultureInfo in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
RegionInfo objRegionInfo = new RegionInfo(ObjectCultureInfo.Name);
if (!objDic.ContainsKey(objRegionInfo.EnglishName))
{
objDic.Add(objRegionInfo.EnglishName, ObjectCultureInfo.Name);
}
}
foreach (KeyValuePair<string, string> val in objDic)
{
ddlCountries.Items.Add(new ListItem(val.Key, val.Value));
}
ddlCountries.SelectedValue = (HttpContext.Current.Profile as ProfileCommon).Preferences.Culture;
}
protected void btnChangeLanguage_Click(object sender, EventArgs e)
{
ProfileCommon profile = HttpContext.Current.Profile as ProfileCommon;
profile.Preferences.Culture = ddlCountries.SelectedValue;
}
}
protected override void InitializeCulture()
{
string culture = (HttpContext.Current.Profile as ProfileCommon).Preferences.Culture;
this.Culture = culture;
this.UICulture = culture;
}
Profile:
<properties>
<add name="FirstName" type="String"/>
<add name="LastName" type="String"/>
<add name="Gender" type="String"/>
<add name="BirthDate" type="DateTime"/>
<add name="Occupation" type="String"/>
<add name="WebSite" type="String"/>
<group name="Preferences">
<add name="Culture" type="String" defaultValue="en-NZ" allowAnonymous="true"/>
</group>
</properties>
是否下拉秀選擇了更新的語言是什麼? – spinon 2010-07-14 04:04:05
不,它會回到配置文件首選項中屬性Culture的默認值 – ONYX 2010-07-14 10:03:22