Using Resource files in Sharepoint

Leave a Comment
While doing SharePoint projects definitely you will have to use resource files to well mange and localize your resources. Not like an ASP.net application SharePoint requires you to deploy resource files to different locations.
To be clear, different operations will look the resource files in two different locations(Web parts refer one location and the resource entries in a feature manifest file looks in another etc…). The two resource locations SharePoint will look into are,
1) C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Resources\
2) The web application Virtual Directory (typically C:\inetpub\wwwroot\wss\VirtualDirectories\ {the web application port number}\App_GlobalResources\
So when we deploy a solution what typically done is coping the resource files to these locations manually.

-> Create one Seperate folder called "MyResources" in your Sharepoint Solution and Elements.xml file to it name it . 
-> Add Resource file underneath it .



-> Now select the Rosource file and set the Properties.



By using the above method we can deploy the resource files in Virtual directory
To deploy in to the 14 hive , follow the below steps
 -> Click on the Show All files @ Solution Explorer then you will find a file SharePointProjectItem.spdata, which is associated with the elements.xml file
 -> Open the File
->add the below entry.

<ProjectItemFile Source="MyResources.resx" Target="Resources\" Type="RootFile" />





Now Deploy the Solution....!!!

Related Post

0 comments:

Post a Comment