首先在App_GlobalResources新建resx資源文件。如:

不同語(yǔ)言的resx中項(xiàng)目應(yīng)該具有相同的名稱:

中文資源項(xiàng)

英文資源項(xiàng)
完了以后就可以使用這些名值對(duì)了,
復(fù)制代碼 代碼如下:
<asp:Literal runat="server" Text="<%$ Resources:lang,userinfo%>" />
復(fù)制代碼 代碼如下:
<%=Resources.lang.userinfo%>
復(fù)制代碼 代碼如下:
void Application_BeginRequest(Object sender, EventArgs e)
{
try
{
if (Request.Cookies["lang"] != null)
{
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(Request.Cookies["lang"].Value.ToString());
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Request.Cookies["lang"].Value.ToString());
}
}
catch (Exception)
{ }
}
新聞熱點(diǎn)
疑難解答
圖片精選