<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="amenities.aspx.cs" Inherits="amenities"%>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server" >
<div>
Change Language
<br />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" >
<asp:ListItem Value="en-US">English</asp:ListItem>
<asp:ListItem Value="ur">Urdu</asp:ListItem>
<asp:ListItem Value="fr">French</asp:ListItem>
</asp:DropDownList>
</div>
<div>
<img src="Images/2.jpg" style="position:relative;top:20px; height:300px;" />
<p style="position:relative;left:454px; top: -300px; width: 619px;"><asp:Label ID="Label2" runat="server" BackColor="<%$ Resources:Resource, BColor %>" ForeColor="<%$ Resources:Resource, FColor %>" Text="<%$ Resources:Resource, Text %>" ></asp:Label></p>
<br /><img src="Images/3.jpg" style="position:relative; height:305px; top: -120px; left: 2px;" />
<p style="position:relative;left:456px; top: -443px; width: 619px; bottom: 2332px;"><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></p>
<br/><img src="Images/4.jpg" style="position:relative;top:-180px; height:330px; left: 5px; width: 450px;" />
<p style="position:relative; top: -530px; left: 460px; width: 617px;">The spectacular happens at all of our hotels and resorts in 80 countries across six continents. Let us find the one that’s right for you. The five-star international Islamabad Marriott Hotel is located at the foot steps of the famous Margalla Hills and is within close proximity to Rawal Lake, the town centre, President & Prime Minister Houses, Ministry of Foreign Affairs, Senate, Parliament House, Foreign Missions, World Bank, Government Offices, corporate sector, Print and Electronic media offices etc. The Hotel is a favourite rendezvous of politicians, diplomats, businessmen and movers and shakers of the country. Owing to the perfect location of the hotel, it hardly takes half an hour to commute between the Hotel, the Islamabad International Airport and the places of interests.</p>
<br/><img src="Images/5.jpg" style="position:relative; top: -372px; left: 488px; width: 587px; height: 249px;" />
<p style="position:relative; top: -638px; left: 1px; width: 481px;">The all-day dining restaurant offers an extensive selection of international & local flavors on a la carte menu but also buffet available for breakfast,lunch,hi-tea and dinner.The restaurant is popular for business lunches,casual dinners and Sunday Brunch</p>
<br/><img src="Images/6.jpg" style="position:relative; top: -424px; left: 485px; height: 276px; width: 590px;" />
<p style="position:relative; top: -718px; left: 2px; width: 478px;">A truly authentic Japenese Restaurant. As you dine with us you will not only savour the sumptous flavour but also the spectacular design that actually makes you feel that you are actually in Japan. Sakura is made to capture your heart and soul imagination. Jason's steakhouse concept is centered around exceptionally high quality food and warm elegent atmosphere. we serve best steak available and uncompromising quality.Two Private Rooms, both with the capacity of 04-persons.</p>
</div>
</asp:Content>
&#13;
我试图在asp中使用全球化。我创建了三个资源文件fr
,ur
和resource
。通过下拉列表选择语言正在发生变化,但我必须使用下拉列表在同一页面上更改其他语言
box1
语言已更改,但如何更改box2
语言?
我在resource
文件中遇到问题如何将2 3和4文本放在同一资源fr
资源文件中,以及如何使用不同标签将每个资源文件标记为链接。
http://prntscr.com/72uhug 请参阅截图 http://prntscr.com/72um08 资源文件屏幕截图
答案 0 :(得分:2)
首先,让自己熟悉concept of Globalization here
,并了解全局和本地资源文件的使用,这些文件完全可以满足您的要求。给出了一个简单的定义here too
。
因此,简而言之,您应该更好地为每种语言生成本地资源,并覆盖InitializeCulture()
方法以设置Page的UICulture
属性,以便在{{1}时选择适当的语言特定文件选择改变。
第1步:生成特定于语言的资源文件(dropdownlist
)
.resx
,那么
Visual Studio创建一个名为default.aspx
的新文件夹,和
在App_LocalResources
文件夹中,一个名为的新文件
App_LocalResources
。在这个default.aspx.resx
中,你应该把
中性语言(英文)文本。 接下来,创建一个特定于法语的资源文件
在解决方案资源管理器中,右键单击default.aspx.resx
文件,然后选择
单击“复制”。
右键单击default.aspx.resx
,然后单击“粘贴”。
Visual Studio创建一个名为App_LocalResourcesfolder
的文件。
将其重命名为Copy of default.aspx.resx
。此资源文件现在表示
法语中的页面内容。
打开default.aspx.fr.resx
并添加法语文本。
以同样的方式为Urdu创建特定于语言的资源文件。 [ 文件名
因此将是:default.aspx.fr.resx
]
第2步:
请记住,Asp.Net将选择适当的语言
资源文件基于Pages的UICulture
值。设置
Page的default.aspx.ur.resx
属性,您必须覆盖UiCulture
方法并在那里设置此属性:
//使用Request.Form [“DropDownList1”]访问DropDownlist值
IntializeCulture()
Read here
有关使用Asp.net创建多语言网站的详细教程