Localize Web 伺服器控制項宣告式語法
更新:2007 年 11 月
在 Web 網頁上建立位置以顯示當地語系化的靜態文字。
<asp:Localize EnableTheming="True|False" EnableViewState="True|False" ID="string" Mode="Transform|PassThrough|Encode" OnDataBinding="DataBinding event handler" OnDisposed="Disposed event handler" OnInit="Init event handler" OnLoad="Load event handler" OnPreRender="PreRender event handler" OnUnload="Unload event handler" runat="server" SkinID="string" Text="string" Visible="True|False" />
備註
使用 Localize 控制項,在 Web 網頁上保留顯示當地語系化文字的位置。Localize 控制項與 Literal 控制項相同,與 Label 控制項類似。雖然 Label 控制項允許您將樣式套用至顯示的文字,但 Localize 控制項不允許。您可以藉由設定 Text 屬性 (繼承自 Literal 控制項),以程式設計方式控制 Localize 控制項中顯示的文字。
範例
下列程式碼範例示範如何使用「當地語系化」控制項來當地語系化靜態文字區塊。App_LocalResource 資料夾中的頁面資源用於自訂不同語言的文字。
<%@ Page Language="VB"
Culture="auto"
meta:resourcekey="PageResource1"
UICulture="auto" %>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Localize Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Localize id="Localize1"
runat="server"
meta:resourcekey="Localize1Resource1"
Text="Hello World!">
</asp:Localize>
</div>
</form>
</body>
</html>
<%@ Page Language="C#"
Culture="auto"
meta:resourcekey="PageResource1"
UICulture="auto" %>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Localize Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Localize id="Localize1"
runat="server"
meta:resourcekey="Localize1Resource1"
Text="Hello World!">
</asp:Localize>
</div>
</form>
</body>
</html>