With web parts there is a special way in which to place resources in the correct folder and have the part deploy and reference them.

Take an image for example. Just drop the Image into the Root of the web part project (no need to separate it into separate folder unless you have lots of course or want to).

This example has a Traffic.jpg in the Web Part Project.

In the manifest is the following :

ClassResources>
ClassResource FileName=”Traffic.jpg”/>
/ClassResources
>

The class can reference the href like this :

this.ClassResourcePath + “/Traffic.jpg”;

To give a Web Part a custom Icon then create a 32×32 gif/png/jpg (pref. gif for transparency), It is displayed at 16×16 though. Make an entry for it in the ClassResource Section, then in the DWP:

PartImageLarge>_WPR_/ICO32.gifPartImageLarge>

Notice the _WPR_, this is automatically replaced by stsadm with the wpresources path (which is the ClassResourcePath) for the specific web part, as this is where it gets deployed.

There is also a PartImageSmall setting which I couldn’t get to work, not enough time to play with it though so I stuck with this.

Advertisements