add

Monday, March 23, 2009

How to use resource file in Sharepoint

Today I will tell you how to use resource file in sharepoint.

Resource file is stored in location '12/Resources' directory.

If you don't know where this '12' folder exists , then the full path is:

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12

There you will see a folder named 'Rescources'.

Suppose we have a resource file named CustomResource.resx with a key/value pair as :

userName : TestUser

Now, if we need to access the value of key userName from resource file from our application, we need to do:

string srcName = SPUtility.GetLocalizedString(
"$Resources:CustomResource,userName", "CustomResource", 1033);


You can also use the above code like this also:

string srcName = SPUtility.GetLocalizedString(
"$Resources:userName", "CustomResource", 1033);




Varun Sharma

No comments: