Reading a String From a Resources File in Asp.Net at RunTime

ok, at present, this information is as difficult to find on the web at the moment as it is stupidly simple.

if you google you most likely are going to come across solutions that new up a ResourceManager class based on a full namespace and an assembly name and most likely you may have run into problems.

If you all you are trying to do is load something from your statically defined Resources file in ASP.Net, all you need to do is use the static ResourceManager property like so:

var resourceManager = ResourceFileName.ResourceManager;
var text = resourceManager.GetString(“keyintheresourcefile”);

You can also get any other objects allowed in a Resources file besides strings such as files or images; you just have to call the right method on the ResourceManager object.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s