多语言开发 之 通过基页类及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);
}
}
选择后 将所选存入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);
}
}
相关文章推荐
- 多语言开发 之 通过基页类及Session 动态响应用户对语言的选择
- .NET开发人员,对于动态语言(Dynamic Languages)应该持什么样的态度
- 3-iOS开发 C语言基础教程 选择分支
- Spring3 整合MyBatis3 配置多数据源 动态选择SqlSessionFactory
- 从 iOS,Objective-C, IPhone, iPad, Android, Java, Node.js 或其他平台,或通过其他开发语言,使用WS-Trust请求一个ADFS的令牌
- struts2通过ajax动态改变系统后台的语言来达到国际化页面切换的功能
- 群雄争霸 动态语言应如何选择?
- servlet学习笔记3——用户登录网站(通过session验证登陆用户)
- 微软CLR团队的动态语言(开发)职位
- 10.app后端选择什么开发语言
- 通过VS中的数据源选择对话框实现数据库连接配置(用户使用)
- 根据用户查询选择动态显示表的数据列
- 开发大型web应用,你会选择什么作为后端语言?
- 微信开发第3章 通过accesstoken获取用户分组
- 没头没尾--项目开发笔记:怎样选择项目开发语言?!
- Winform开发框架之权限管理系统改进的经验总结(2)-用户选择界面的设计
- 用PHP编程语言开发动态WAP页面
- Windows Mobile开发应该选择哪种开发语言?
- 通过HttpSessionListener 实现 在线用户 .
- 微信开发第5章 通过accesstoken获取用户基本信息并修改用户备注