All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
教你如何在Perl下连接Access数据库_php资料_编程技术
ASP.NET,MVC+LINQ开发一个图书销售站点(1)-需求分析_[Asp.Net教程]
Delphi使用ADO连接SQL Server 2000数据库
动态sql语句基本语法_[SQL Server教程]
.net仿照51job网站地区选择效果_[Asp.Net教程]
什么是面向对象编程
用javascript轻松制作抽奖系统_JavaScript技术_编程技术
ASP.NET中设置默认提交按钮的代码_[Asp.Net教程]
asp.net,2.0的文件上传(突破上传限制4M)_[Asp.Net教程]
PHP学习宝典-第四章_[PHP教程]
Reading number is top 10 pictures
Female star bikini
Sora aoi on twitter3
Sora aoi in China1
分手的感悟
So beauty, will let you spray blood7
毕姥爷事件,告诉你6条真理
Photographed the passion of the clients and prostitutes in the sex trade picture1
宝贝系列
运动的范冰冰3
水晶头骨造型的酒瓶
Download software ranking
Unix video tutorial14
Boxer Classic video1
Rio big adventure
Boxer's Top ten classic battle5
Be there or be square
Professional killers2 data package
Unix video tutorial2
Unix video tutorial15
艳兽都市
美女游泳记









<%=Resource("language") %>:














Label:











Label:









aspx.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


来源:http://www.cnblogs.com/harryguo


归海一刀 published in(发表于) 2014/1/30 1:17:46 Edit(编辑)
Asp.net2.0实现多语言网页的方法_[Asp.Net教程]

Asp.net2.0实现多语言网页的方法_[Asp.Net教程]

Asp.net2.0实现多语言网页的方法_[Asp.Net教程]
结合网上的资料实现了网页的多语言.其中有简体中文,繁体中文,英文三个.主要步骤是:

1.首先建立资源文件strings.resx,再建立strings.en-us.resx,strings.zh-cn.resx,strings.zh_hk.resx.必须要有strings.resx,这个文件可以没有任何内容.但必须有.不然在下面的default.aspx.cs中,visual studio会自动提示把这些资源文件放在App_GlobalResources目录下.

#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


中 Resources.strings.ResourceManager就会访问不到

2.应用程序根目录下建立有时候叫做 ASP.NET 应用程序文件Global.asax.增加以下代码

void Application_BeginRequest(object sender, EventArgs e)
{
try
{
if (Request.Cookies["CultureResource"] != null)
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Request.Cookies["CultureResource"].Value);
else
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(ConfigurationSettings.AppSettings["DefaultCulture"].ToString());
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
}
catch (Exception)
{
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(ConfigurationSettings.AppSettings["DefaultCulture"].ToString());
}

}

每次访问页面时,程序都在运行这段代码一次.不知道有谁能有更好的方法.我觉得这样不是很好.麻烦提示哦!

3.以下是页面的代码

aspx




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.