Asp.net 4 and C#.

I have a string in my Code Behind. I would like assign a value depending on the User's Browser region.

I'm trying with this code, no error, but does not work (no value to a String has been assigned).

Any idea how to solve it? Thanks

   string textPrevious = "<%$ Resources:Global, CategoryListSubCategories %>";
有帮助吗?

解决方案

I found out the solution myself: Just use Resources.Global.

string textPrevious = Resources.Global.CategoryListSubCategories;

Useful article: http://shan-tech.blogspot.com/2007/02/aspnet-20-localization-of-string.html

其他提示

You can do like...

string textPrevious = Resources.Global.CategoryListSubCategories;

You can build an ExpressionBuilder to access the code-behind string. The article .NET String Resources includes the class StringExpressionBuilder with the expression Strings:

<asp:Label ID="AppTextLabel" runat="server" 
    Text="<%$ Strings:MyCompany.MyApp.MyStrings, AppText %>" />
<asp:Label ID="LibTextLabel" runat="server" 
    Text="<%$ Strings:MyCompany.MyLib.MyStrings, LibText %>" />
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top