Monday, October 25, 2010

How to Read Resource file values in Sharepoint 2007

How to Read values from Resource files in Sharepoint 2007.

In sharepoint the Resource files can be placed in many places. Some of them are listed below.

1. Under 12\Resources

The resources which needs to be placed by the time of provisioning itself can be placed under this. The values can be retired in code by as follows.

Through c#

a. string strTrial = SPUtility.GetLocalizedString("$Resources:

spscore,Key", "spscore", web.Language);

web -> Current web.

From XML

b. Title="$Resources:spscore, Key"

i.e., The Title of the Feature, Description etc can be taken from this location.

2. Under 12\Config\Resources

We cannot retrieve the data from here. The resource files should be copied to Virtual Directories.

3. Under Virtual Directories

String strTrial = HttpContext.GetGlobalResourceObject("Resource File name without Extn", "Key", new System.Globalization.CultureInfo(Convert.ToInt32(web.Language))))



4. Under the Feature Folder

string strTrial = SPUtility.GetLocalizedString("$Resources:

spscore,Key", "spscore", web.Language);

web -> Current web.

1 comment:

Vergil said...
This comment has been removed by the author.