I'm developing a few web parts and I have a Sharepoint site with 2 sub-sites:
hxxp://sharepointserver/sites/portal1
hxxp://sharepointserver/sites/portal2
(hxxp to get around the spam filter)
In the local file system, the site is created in:
C:\Inetpub\wwwroot\wss\8080\
There are a few images, a couple of javascript files and a css file that get installed in (stsadm -globalinstall):
C:\Inetpub\wwwroot\wss\8080\wpresources\mywebparts\
Now the problem is when I use the ClassResourcePath property from a web part, depending on what site the web part has been added to, the url is (for example):
hxxp://sharepointserver/sites/portal[1|2]/wpresour开发者_开发问答ces/mywebparts/mywebparts.css
This fails as the file url should be:
hxxp://sharepointserver/wpresources/mywebparts/mywebparts.css
It feels like I am using the ClassResourcePath incorrectly, but I'm not sure what other options there are to share common files between web parts?
Thanks
There are some options:
You can put the common files in the _layouts directory. If you are using MOSS 2007 you can use solution deployment to automate this. http://msdn.microsoft.com/en-us/magazine/cc163379.aspx
You can embed your resources in the assembly itself. And then access it: http://support.microsoft.com/kb/319292
精彩评论