How do I access GetGlobalResourceObject function from a class that is not a page?

Shimmy Weitzhandler picture Shimmy Weitzhandler · Jul 10, 2009 · Viewed 30.4k times · Source

I have a class in my asp.net proj, I would like to get access GetGlobalResourceObject (that page exposes), from anywhere in the site, possible?

In other words I wanna access the global resources from a class that is not a page I don't care how.

Answer

Shimmy Weitzhandler picture Shimmy Weitzhandler · Jul 10, 2009

Answer: Yes, as following pseudo:

Resources.<The name of the resources file name>.<your resource key>;

Example:

lblTitle.Text = Resources.MySettings.WebsiteTitle;

Resources is an Visual-Studio auto generated namespace that exposes all the global resource classes and props in the project.