Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access global resources in an asp.net control

meta:resourcekey="WizardStep1Resource1"

This is what I use to access a App_LocalResources.

How do I access a resource in App_GlobalResources?

SOLUTION: Create a resource called Globalresource.resx in App_GlobalResources. In the file set a property called Test with the text Hello. Then it is called like Text='<%$ Resources:GlobalResource, Test%>'

like image 478
joncodo Avatar asked Sep 13 '11 16:09

joncodo


People also ask

How can you retrieve global resources programmatically?

Call the GetLocalResourceObject or GetGlobalResourceObject method to read specific resources from a global or local resource file, respectively. These overloaded methods are available in the HttpContext and TemplateControl classes.

How do you call a resource file in .NET core?

Create a folder in whatever project you want to store the resx files in - default, call it "Resources". Create a new resx file with the specific culture and the file name you'll look up later: If you had a shared one, you could do: SharedResource. en-US. resx.

What are local resources and global resources?

A local resource is specific to a certain page, which is the only one who can access it, while global resources can be accessed from anywhere. Local resources are kept in the special App_LocalResources folder, while global resources are kept in the App_GlobalResources folder.


2 Answers

Text='<%$ Resources:Resource, WizardStep1Resource1 %>'

Text is the name of the property you want to set. Resource is the name of the global Resourcefile resp. ResourceClass and WizardStep1Resource1 is the name of the Resource Text.

See here: http://msdn.microsoft.com/en-us/magazine/cc163566.aspx

like image 117
slfan Avatar answered Sep 19 '22 14:09

slfan


You can only access a resource in App_GlobalResources explicitly, using the implicit wiring i.e. meta:resourcekey="WizardStep1Resource1" is applicable only for local resources

http://msdn.microsoft.com/en-us/library/ms227427.aspx

To access a resource in App_GlobalResources, use explicit localization like

   <%= (string)GetGlobalResourceObject("ResourcesClass", "WizardStep1Resource1") %>
like image 43
chridam Avatar answered Sep 20 '22 14:09

chridam