20050104 关于多语言版本的试验

博客介绍了使用ASP.NET发送邮件的文章链接,还详细阐述了多语言版本的实现问题。包括在web.config中的配置,在global.asax.cs里的Application_Start和Application_BeginRequest方法的代码,以及页面调用时的引用、全局变量设置和控件显示的代码。


小W说象冬眠还未苏醒。与前几天比,天气变的异常的热,也该醒过来了。
看到有关发邮件的文章,试了一下,竟然成功,略微给麻木的神经一点刺激。
文章链接如下:
使用asp.net发送邮件详解  Night
http://zealot.yculblog.com/post-322074.html
asp.net发送email  陈睿
http://www.cnblogs.com/chenruibuaa/archive/2004/09/17/44218.aspx

关于多语言版本的实现问题,在网上找来找去,还是看微软的帮助最有用。
1、web.config
 <configuration>
    <appSettings>    
   <add key="DefaultCulture" value="zh-CN" />
   <add key="EnglishCulture" value="en-US" />
   </appSettings> 
  <system.web>
2、global.asax.cs
//引用
using System.Globalization;
using System.Resources;
using System.Threading;
using System.IO;
using System.Configuration;
using System.Reflection;

//Application_Start
 protected void Application_Start(Object sender, EventArgs e)
  {
   Application["CI"] = CultureInfo.CreateSpecificCulture(ConfigurationSettings.AppSettings["DefaultCulture"]);
   //excel1.Resources.IMS-EG  命名空间隔.文件夹名.文件名
   Application["RM"]  = new ResourceManager("excel1.Resources.IMS-EG", Assembly.GetExecutingAssembly() ) ;      
  }

//Application_BeginRequest
  protected void Application_BeginRequest(Object sender, EventArgs e)
  {
   try
   {
    Thread.CurrentThread.CurrentCulture =CultureInfo.CreateSpecificCulture(ConfigurationSettings.AppSettings["DefaultCulture"]);
   }
   catch(Exception)
   {
    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");
   }
   Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
  }
3、页面调用
//引用
using System.Globalization;
using System.Resources;
using System.Threading;
using System.Configuration;
//全局变量
protected System.Web.UI.WebControls.Label lblTest;
protected ResourceManager rm;
protected CultureInfo ci;
//Page_Load
 private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   rm = (ResourceManager) Application["RM"];
   ci = (CultureInfo) Application["CI"];
  }
//控件的显示
this.lblTest.Text=rm.GetString("sQueryResult",ci);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值