-1

I can access language resource file values in mark up fine using below code:

<%=Resources.MainResource.MyKey%>

But I cannot do the same in code behind. Shouldn't it just be as follows:

Dim MyValue = Resources.MainResource.MyKey
Veve
  • 6,643
  • 5
  • 39
  • 58
user3656029
  • 101
  • 1
  • 14

1 Answers1

2

I have done the following:

  • Added an App_GlobalResources Folder to my project
  • Added to this folder a Resource file with the Name "Resource1"
  • Then I created a Key with the name "String1" and the value = "hi" in this resource file
  • In codebehind I did the following to take this key's value and initialize some variable with this value

c#

string s = (string)GetGlobalResourceObject("Resource1", "String1");
lit.Text = s;

And it works. It showed me "hi" for the label on my ASP.NET page.

Khazratbek
  • 1,656
  • 2
  • 10
  • 17
STORM
  • 4,005
  • 11
  • 49
  • 98