3

次のように、App_Themes のテーマのフォルダー内の App_LocalResources フォルダーにリソース ファイルを配置しました: \App_Themes\Theme1\App_LocalResources\Resources1.aspx.resx

Web フォームの名前が Resources1.aspx で Theme="Theme1" であると仮定すると、プロジェクトの Web フォームからこのファイルのリソースにアクセスするにはどうすればよいですか?

4

2 に答える 2

1

\ App_GlobalResources\Generic.resxにあるglobalresourcesに;でアクセスできます。

<%= Resources.Generic.Cancel %>

ローカルリソースはApp_LocalResourcesフォルダーにありますが、必ずしもルートフォルダーに配置する必要はありません。ローカルリソースの場合は次のようになります。

<%$ Resources:Cancel%>

また

string labelCancel = GetLocalResourceObject("Cancel").ToString();

テーマフォルダにリソースファイルを配置する限り、テーマとリソースを分離し、グローバルリソースを利用して、サイトマスター/ベースページなどのさまざまなリソースをプログラムで切り替えます。

于 2009-02-16T13:55:17.833 に答える
1

You can use the "Resources" expression to extract values from the resource file, for instance:

<h1><%$ Resources: H1 %></h1>

Alternatively, and especially if you're in code-behind, use GetLocalResourceObject:

h1.InnerText = GetLocalResourceObject ( "H1" ).ToString ( );

EDIT: Sometimes i answer too fast; i don't think themes are localizable in that sense, however there are some workarounds. You could have theme specific items in the resource file and access them depending on current theme.

于 2009-02-16T12:38:53.760 に答える