spx.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Resources;
using System.Globalization;
using System.Reflection;
using Microsoft.VisualBasic;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Resource("LoginName");
Label2.Text = Resource("Password");
}
Resource#region Resource
public string Resource(string key)
{
string resourceValue = null;
CultureInfo ci = CultureInfo.CurrentCulture;
ResourceManager rm = Resources.strings.ResourceManager;
resourceValue = rm.GetString(key, ci);
return resourceValue;
}
#endregion
protected void Button1_Click(object sender, EventArgs e)
{
this.UpdateCultureCookie(ConfigurationSettings.AppSettings["CNCulture"].ToString());
System.Web.UI.Page currentPage = (System.Web.UI.Page)this;
Response.Redirect(currentPage.Request.Url.ToString());
}
protected void Button2_Click(object sender, EventArgs e)
{
this.UpdateCultureCookie(ConfigurationSettings.AppSettings["ENCulture"].ToString());
System.Web.UI.Page currentPage = (System.Web.UI.Page)this;
Response.Redirect(currentPage.Request.Url.ToString());
}
}
strings.zh-cn.resx
在视图下增加三个字段
language 请选择语言
LoginName 用户名
Password 密码
同样strings.zh-hk.resx
language 請選擇語言
LoginName 用戶名
Password 密碼
string.en-us.resx
language Please Select Language
LoginName Username
Password Password