2010-09-22

Using, embedding and deploying resources (gif, css, javascripts, etc) when writing SharePoint 2010 web parts

I came across an article by Maurice Prather, "Web Part Class Resources - a forgotten storage location", and I also failed to answer his question; What are Web Part resources? I've never thought about this way of deploying resources used by and in my web parts. I've more or less always used the "classical" way of deploying my images, css, js, etc to the /layouts/mydirectory. That may change in the future!

But here is also anohter option, and that is to deploy the resources as WebResource. I'm not 100 % sure that I can answer you when to use what method, but i gues WebResources should be used in non-webparts scenarios, and/or SharePoint solutions where the same resource is to be used by different sharepoint items (Web parts, Application Pages, etc).

On CodeProject you'll find a working example where both methods have been used: Site Map Web Part.

No comments: