.aspx
<asp:Button ID="btnEnglish" CssClass="btn" runat="server" BackColor="White" BorderStyle="None"
Text="English" Width="60px" onclick="btnEnglish_Click" TabIndex="5" />
<asp:Button ID="btnChinese" CssClass="btn" runat="server" BackColor="White" BorderStyle="None"
Text="简体中文" Width="60px" onclick="btnChinese_Click" TabIndex="6" />
Text="English" Width="60px" onclick="btnEnglish_Click" TabIndex="5" />
<asp:Button ID="btnChinese" CssClass="btn" runat="server" BackColor="White" BorderStyle="None"
Text="简体中文" Width="60px" onclick="btnChinese_Click" TabIndex="6" />
.cs
private void Localize()//从语言文件中获取数据
{
Page.Title = this.GetString("T0190");// "物料管控系统身份验证";
lblUserCode.Text = this.GetString("T0164") ;
}
{
Page.Title = this.GetString("T0190");// "物料管控系统身份验证";
lblUserCode.Text = this.GetString("T0164") ;
}
protected void btnEnglish_Click(object sender, EventArgs e)
{
Response.Cookies["LANGUAGE"].Expires = DateTime.Now.AddMonths(3);
Response.Cookies["LANGUAGE"].Value = "en-US";
CurrentSession.Language = "en-US";
Response.Redirect("login.aspx?msg=" + msgStr + "&sourceUrl=" + sourceUrl);
}
protected void btnChinese_Click(object sender, EventArgs e)
{
Response.Cookies["LANGUAGE"].Expires = DateTime.Now.AddMonths(3);
Response.Cookies["LANGUAGE"].Value = "zh-TW";
CurrentSession.Language = "zh-TW";
Response.Redirect("login.aspx?msg=" + msgStr + "&sourceUrl=" + sourceUrl);
}
.cs 类
public string GetString(string strNo) {
//多語言支持
//ResourceManager rm = new ResourceManager("TravelRequest.Common.Resource", Assembly.GetExecutingAssembly()); //For VS2003
//return rm.GetString(strNo);
//多語言支持
//ResourceManager rm = new ResourceManager("TravelRequest.Common.Resource", Assembly.GetExecutingAssembly()); //For VS2003
//return rm.GetString(strNo);
//return Resources.MultiLang.ResourceManager.GetString(strNo); //For VS2005
return (String)GetGlobalResourceObject("MultiLang", strNo);
return (String)GetGlobalResourceObject("MultiLang", strNo);
}