Resource 学习笔记

//=============================================================
<asp:Button ID="Button1" runat="server" Text="" ToolTip="" meta:resourcekey="Button1Resource1" />

Name / Value
Button1Resource1.Text / My Button
Button1Resource1.ToolTip / My Custom Tooltip
//=============================================================

<%@ Page meta:resourcekey="PageResource1" Language="C#"......

Name / Value
PageResource1.Title / My Page Title

//=============================================================

The Culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on.
The UICulture value determines which resources are loaded for the page.

//=============================================================
<!--App_LocalResources-->
<asp:localize ID="Localize1" runat="server" Text="<%$Resources:,description %>"></asp:localize>

<!--App_GlobalResources : LocalizedText.resx-->
<asp:Localize ID="Localize2" runat="server" Text="<%$resources:LocalizedText,Description %>"></asp:Localize>

<!--App_LocalResources-->
<asp:Label ID="Label1" runat="server" Text="<%$Resources:,SID %>"></asp:Label>
//=============================================================

<%@ Page UICulture="en-US" Culture="en-US" %>
<%@ Page UICulture="zh-CN" Culture="zh-CN" %>
<%@ Page UICulture="zh-TW" Culture="zh-TW" %>

<%@ Page Language="C#" Theme="Classic" UICulture="zh-TW" Culture="zh-TW"......


protected override void InitializeCulture()
    {
        System.Threading.Thread.CurrentThread.CurrentCulture =
            System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
        System.Threading.Thread.CurrentThread.CurrentUICulture =
            new System.Globalization.CultureInfo("en-US");

        //or
        Page.Culture = "zh-CN";
        Page.UICulture = "zh-CN";

        base.InitializeCulture();
    }


protected void Page_PreInit(object sender, EventArgs e)
    {
        this.Theme = "Modern";
    }


this.txtTest.Text = GetLocalResourceObject("BIRTHDAY").ToString();
this.txtTest.Text += (String)GetGlobalResourceObject("LocalizedText", "Description");

//To retrieve global resources using strong typing
this.txtTest.Text += Resources.LocalizedText.Description;

web.config:
<system.web>
...
<globalization culture="Auto" uiCulture="Auto" fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8"/>
...

<%@ Page RequestEncoding="utf-8" ResponseEncoding="utf-8" %>

 

 

 

 


 

posted @ 2007-08-30 14:37  RobotTech  阅读(416)  评论(0编辑  收藏  举报