要在asp.net 2.0 用国际化而且要动态切换语言,步骤如下:

 

在登录页面选择语言,保存到Session或Cookie里面

 HttpContext.Current.Session["Lang"] = ddlLanguage.SelectedValue;


然后其他Web页面都继承自己写的BasePage

 

在BasePage.cs 重写InitializeCulture方法

        protected override void InitializeCulture()
        {
            StrCulture =(String)Session["Lang"];

            if (!string.IsNullOrEmpty(StrCulture))
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(StrCulture);
            
            }
            base.InitializeCulture();
        } 

相关文章:

  • 2021-06-26
  • 2021-10-25
  • 2021-10-21
  • 2022-12-23
  • 2021-06-22
  • 2022-12-23
  • 2021-09-29
  • 2021-07-27
猜你喜欢
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2021-05-06
  • 2022-12-23
相关资源
相似解决方案