0

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 %>";

3 Answers 3

4

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

Sign up to request clarification or add additional context in comments.

Comments

4

You can do like...

string textPrevious = Resources.Global.CategoryListSubCategories;

2 Comments

Thanks I found the same solution
I was just late in typing and finding the similar thing from one of my project the same for you.
0

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 %>" />

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.