您的位置:首页 > 其它

多语言开发 之 通过基页类及Session 动态响应用户对语言的选择

2009-06-30 11:30 363 查看
在用户通过UserLogin.aspx登录系统时 提供其对语言的选择
选择后 将所选存入Session 以便登录系统后的其他页面进行按语言显示
当然相关页面需要支持多语言
具体信息可参看
使用 根据语言环境不同 而显示不同的 资源本地化 ASP.NET 网页
App_Code下定义基页类 BasePage.cs

Code
public partial class UserLogin : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["myCurrentUICulture"] != null && Session["myCurrentCulture"] != null)
{
if (Session["myCurrentUICulture"].ToString() != "" && Session["myCurrentCulture"].ToString() != "")
{
this.ddl_Language.SelectedValue = Session["myCurrentUICulture"].ToString();//
}
}
else
{
string str = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString();
this.ddl_Language.SelectedValue = str;//
Session["myCurrentUICulture"] = this.ddl_Language.SelectedValue;
Session["myCurrentCulture"] = this.ddl_Language.SelectedValue;
}
}
}

protected void ddl_Language_SelectedIndexChanged(object sender, EventArgs e)
{
Session["myCurrentUICulture"] = this.ddl_Language.SelectedValue;
Session["myCurrentCulture"] = this.ddl_Language.SelectedValue;

Response.Redirect("UserLogin.aspx",true);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: