asp.net中主页的本地化 [英] Localization on Masterpage in asp.net
问题描述
我知道我们可以在ASP.NET页面中使用本地化模式,这使得可以使用多语言Web应用程序。我为Master页面尝试了相同的技术,但它不起作用。
我有一个登录页面,在登录页面上有选择选择网站语言
如果登录成功,则重定向到主页...
登录页面是一个独立的页面,但其余包括主页有一个主页面
主页有5/6个链接按钮。
事情是,我想改变文字根据登录页面选择的语言,这6个链接按钮。
我几乎没有googled,也没有发现有帮助
有什么想法吗?
谢谢
我用过的代码是
I know we can use localization pattern in ASP.NET pages which makes possible to have multi-language web application. I tried same technique for Master page but it does not work.
I have a login page, and in the login page there is option to select language for the website
and if the login is successfull,then redirecting to home page...
Login page is a stand alone page, but the rest include Homepage is having a masterpage
the masterpage have 5/6 linkbuttons.
The thing is, i want to change the text of those 6 linkbuttons according to language selected at login page.
I googled hardly, and nothing found helpfull
Any idea?
Thanks
The code i used is
protected override void InitializeCulture()
{
string currentCulture =Convert.ToString(Session["Language"].ToString());
if (!string.IsNullOrEmpty(currentCulture))
currentCulture = currentCulture;
else
currentCulture = "en-US";
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentCulture);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(currentCulture);
base.InitializeCulture();
}
推荐答案
参考下面文章。
使用ASP.Net 4的多语言Web应用程序 [ ^ ]
希望它有所帮助。
Hi,
refer the below article.
Multi-lingual web applications using ASP.Net 4[^]
hope it helps.
如何遵循CodeProject文章:
使用MasterPage和本地化开发ASP.NET页面 [ ^ ]
我通过Google搜索找到主页面本地化...
最初,我认为那很难在我googled almost是一个语法错误。
What about following CodeProject article:
Developing an ASP.NET page with MasterPage and Localization[^]
I found it by googling for master page localization...
Originally, I thought that that "hardly" in "I googled hardly" was a grammar error.
将代码放在母版页的页面加载中
Put the code in the page load of masterpage
protected void Page_Load(object sender, EventArgs e)
{
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(Session["Language"].ToString());
//System.Threading.Thread.CurrentThread.CurrentCulture =
//ci;
System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
}
此处会话[语言]包含语言码。它从登录页面存储到会话变量
谢谢
Here Session["Language"] contains the language code. and it is stored to the session variable
from login page
Thanks
这篇关于asp.net中主页的本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!