惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
AWS News Blog
AWS News Blog
V
Vulnerabilities – Threatpost
D
Darknet – Hacking Tools, Hacker News & Cyber Security
量子位
博客园 - 叶小钗
AI
AI
T
Tor Project blog
Forbes - Security
Forbes - Security
W
WeLiveSecurity
博客园_首页
爱范儿
爱范儿
J
Java Code Geeks
B
Blog
G
GRAHAM CLULEY
aimingoo的专栏
aimingoo的专栏
Cloudbric
Cloudbric
C
CXSECURITY Database RSS Feed - CXSecurity.com
TaoSecurity Blog
TaoSecurity Blog
L
LINUX DO - 热门话题
阮一峰的网络日志
阮一峰的网络日志
有赞技术团队
有赞技术团队
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Simon Willison's Weblog
Simon Willison's Weblog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
H
Help Net Security
博客园 - 三生石上(FineUI控件)
C
Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
P
Palo Alto Networks Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Commits to openclaw:main
Recent Commits to openclaw:main
博客园 - 司徒正美
The Last Watchdog
The Last Watchdog
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
S
Secure Thoughts
Spread Privacy
Spread Privacy
F
Fortinet All Blogs
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
About on SuperTechFans
Security Latest
Security Latest
Webroot Blog
Webroot Blog
Scott Helme
Scott Helme
Hugging Face - Blog
Hugging Face - Blog

博客园 - 搞IT的狐狸

ASP.Net动态使用CSS - 搞IT的狐狸 - 博客园 SqlDataReader或DATATABLE DATASET 到EXCEL [转载]ROW_NUM实现分页 VS2005 TreeView 的 CheckBox 被点击时的引发页面回发事件 (转发) ASP.NET 2.0,C#----利用GridView控件导出其他文件(导出Excel,导出Word文件) 什么是SHTML 如何使用IFRAM JS来刷新UpdatePanel 随即验证码实现(根据韩现龙代码修改) [北京]招聘 网站设计师 我这半个月的代码总结(小技巧,小代码)之二 我这半个月的代码总结(小技巧,小代码)之一 用Themes实现网站换肤 将数据控件(如GridView)的内容转化成Excel格式文件 ASP.NET新手实用技巧!(C#) 学历不高!写给自己!自勉! 一张笑死我又让我辛酸的图片!开发人员的辛酸! 服务器刚开,凑个沙发!.NET几点你应该知道的细节! 求动态绑定控件ID的值的方法!着急!
(转载)ASP.NET本地化
搞IT的狐狸 · 2008-04-07 · via 博客园 - 搞IT的狐狸

譬如我有一个登陆页面,上面有两个Label和两个Textbox,页面命名为Login.aspx,控件命名为lbl_UserName,lbl_Password,txt_UserName,txt_Password。

首先可以在网站上新建一个App_LocalResources的文件夹,然后新建一个资源文件,命名为Login.aspx.resx
命名需要跟匹配的页面名字相同。然后再新建另一个资源文件,命名为Login.aspx.zh-Cn.resx

Login.aspx.resx 这个为默认的,而Login.aspx.zh-Cn.resx这个为当浏览器默认语言设为中文的时候调用的。

打开Login.aspx.resx文件:      
名称                             值

LabelResource1.Text   Username
LabelResource2.Text   Password

打开Login.aspx.zh-Cn.resx文件:
名称                                值:

LabelResource1.Text    用户名
LabelResource2.Text 密码

然后,在我们的页面代码中

1<asp:Label ID="lbl_UserName" runat="server"></asp:Label>
2<asp:Label ID="lbl_Password" runat="server"></asp:Label>

改为

1<asp:Label ID="lbl_UserName" runat="server" Text="<%$ Resources:LabelResource1.Text %>"></asp:Label>
2<asp:Label ID="lbl_Password" runat="server"  Text="<%$ Resources:LabelResource2.Text %>"></asp:Label>
3

最后,在页面的Page属性中,加上 Culture="auto:zh-Cn" UICulture="auto:zh-Cn" ,默认设为了中文。

编译便可以看到效果,当浏览器默认语言为英文时,可以看到两个Label的显示为Username和Password。
当浏览器默认语言为中文时,可以看到两个Label的显示为用户名和密码。

-------------------------------自己新写的---------------------------------------------------------
ASP.NET里不需要这么麻烦

也不需要编译了

HttpContext.GetGlobalResourceObject("资源文件名(不写扩展名)", "要取的ID(标记)");
一句话搞定