2014-09-25 39 views
0

在我的解決方案中,我有一個文件夾App_GlobalResources。 在我的文件夾App_GlobalResources中,我有兩個文件Lang.fr.resx和Lang.resx。從資源文件動態獲取價值

在運行時,我想,以決定應加載的文件,並採取從該文件中的文本

當我寫了下面的代碼,它顯示我爲:

The resource class for this page was not found. Please check if the resource file exists and try again. 

colName = GetLocalResourceObject("ColumnNamePrefix_" + colName.Substring(0, colName.Length - 3)).ToString(); 

誰能告訴我該怎麼辦?

回答

0

如果是在App_GlobalResources中您想使用GetGlobalResourceObject

有一個過載需要CultureInfo,這就是您可以如何指定默認(我假設英語?)或您的法語版本。應該是這樣的:

CultureInfo culture = CultureInfo.CreateSpecificCulture("fr-FR"); 
HttpContext.GetGlobalResourceObject("ColumnNamePrefix_" + colName.Substring(0, colName.Length - 3), 
    "Lang", culture);