62,041
社区成员
发帖
与我相关
我的任务
分享
<profile enabled="true" >
<properties>
<add name ="MyCultrue" defaultValue="en-us" allowAnonymous="true"/>
</properties>
</profile>
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.RadioButtonList1.Items.Add(new ListItem("英语-English", "en-us"));
this.RadioButtonList1.Items.Add(new ListItem("中文-Chinese", "zh-cn"));
this.RadioButtonList1.AutoPostBack = true;
this.RadioButtonList1.Items.FindByValue(Profile.MyCultrue).Selected = true;
}
}
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedValue.ToLower() != Profile.MyCultrue.ToLower())
{
Profile.SetPropertyValue("MyCultrue", RadioButtonList1.SelectedValue);
Response.Redirect(Request.Url.LocalPath);
}
}
protected override void InitializeCulture()
{
base.InitializeCulture();
System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Profile.MyCultrue);
System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(Profile.MyCultrue);
}
}