.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);
}
Kyle
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步