2011-02-17 5 views
1

내가 다음 링크에서 지침에 따라 사용자 정의 자원 제공자를 만든 : 나는 다음과 같은 코드를 사용하고 있습니다에서 .aspx 페이지에 http://asp-net-whidbey.blogspot.com/2006/03/aspnet-20-custom-resource-provider.html- 사용자 지정 리소스 공급자에서 문자열 값을 읽는 방법?

을하고 그것을 잘 작동 :

<asp:Literal ID="ltlFoo" runat="server" Text="<%$ Resources:SomeText %>" /> 

지금 내가 좋아하는 것 코드에서 지역화 된 값을 읽으십시오.

string foo = Resources.GetString("SomeText"); 

문제점은 자원 관리자를 인스턴스화하는 방법을 모르겠다는 것입니다.
도움이 될 것입니다.

는 편집 :
나는 다음과 같은 코드를 사용하고 위대한 작품 : 그 코드를 사용하지 말아야 어떤 이유는

string foo = (string)GetGlobalResourceObject("", "SomeText"); 

있습니까?

답변

1

따라서 리소스 관리자에 이름이 있어야하며 다음과 비슷한 작업을 수행 할 수 있어야합니다.

// Create a resource manager to retrieve resources. 
     ResourceManager rm = new ResourceManager("items", 
      Assembly.GetExecutingAssembly()); 


// Retrieve the value of the string resource named "welcome". 
// The resource manager will retrieve the value of the 
// localized resource using the caller's current culture setting. 
String foo = rm.GetString("SomeText"); 

Taken From MSDN Example

+0

어떻게 자원 관리자의 이름을받을 수 있나요? –

관련 문제