0

Asp.net 4 和 C#。

我的代码后面有一个string。我想根据用户的浏览器区域分配一个值。

我正在尝试使用此代码,没有错误,但不起作用(没有为字符串分配值)。

知道如何解决吗?谢谢

   string textPrevious = "<%$ Resources:Global, CategoryListSubCategories %>";
4

3 回答 3

4

我自己找到了解决方案:只需使用Resources.Global.

string textPrevious = Resources.Global.CategoryListSubCategories;

有用的文章: http ://shan-tech.blogspot.com/2007/02/aspnet-20-localization-of-string.html

于 2011-08-18T08:16:48.827 回答
4

你可以这样做...

string textPrevious = Resources.Global.CategoryListSubCategories;
于 2011-08-18T08:17:22.057 回答
0

您可以构建一个ExpressionBuilder来访问代码隐藏字符串。.NET String Resources一文包括带有表达式 Strings的类StringExpressionBuilder :

<asp:Label ID="AppTextLabel" runat="server" 
    Text="<%$ Strings:MyCompany.MyApp.MyStrings, AppText %>" />
<asp:Label ID="LibTextLabel" runat="server" 
    Text="<%$ Strings:MyCompany.MyLib.MyStrings, LibText %>" />
于 2011-09-11T20:54:56.307 回答