Question

I'm using VS 2010 to create a SP 2010 web part. I want to include my images, css files and js files in the VS project, and have them be deployed to the correct location. My understanding is that I should be using SPWebPartManager.GetClassResourcePath() to get the urls for these items, and that the files should end up in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\wpresources\{web part name}\{version}__{pk token}.

  1. Is the above correct, or is there a better way?

  2. How to I include these fines in the VS project so that they are deployed to this location - e.g. is there a SharePoint mapped folder I have to put them in?

Was it helpful?

Solution

To deploy it to the wpresources location then you add the resources to the SPI (SharePoint item) in Visual Studio. For instance righ-click on a Web Part item and then add an existing item. Select the new item and look at its properties (F4) and check the Deployment Type. It should be set to NoDeployment by default. Change it to ClassResource...tada...done!

This will add the necessary XML elements (ClassResources/ClassResource) to your package

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top