A place for Sharepoint and rantings
Archive for August, 2005
WebPart Skins
Aug 15th
First Apologies, I pulled the code from the previous articles as I wanted to ensure that it at least compiled, so I spent some time creating a full working version which I’m publishing here.
So. Web Part Skins. This is different to just altering the CSS it combines having a base class for your custom webparts that modifies the render mechanism. Luckily there are two handy methods that MS provide in the API that give you the HTML that surrounds the Web Part (GetDesignTimeHeader, GetDesignTimeFooter), from that you can regex it till your hearts content.
You could extend this further by using the techniques described in http://blog.spsclerics.com/archive/2005/07/11/5421.aspx A rounded Corner header for webPart.
One drawback of this is that it is only for your own custom web parts as you need to inherit from WebPartBase (or just code it in directly). It is possible to replace the MS Content Editor in Sharepoint by editing the DWP files in the Area Template Folders and point it at a new one you create yourself. I have done this on a Portal (I also removed the HTML edit button in mine so no-one goes putting Jscript directly in the editor part, you could also run a HTML validator More >
WebPartVersion extension of WebPartBase
Aug 11th
Whilst developing web parts our team came across some interesting phenomenon, mainly that if you version your web parts using standard .Net assemblyVersion then upgrades work fine as Sharepoint would automatically upgrade the internally held dwp files for every occurrence of the web part you may have in Sharepoint.
This is fine moving forward, a little unnerving perhaps but fine. What we did discover is that if you had to roll-back that version then too late you can’t as in an uninstall scenario the dwp’s are not updated.
We wondered why you would need to update dwp’s in Sharepoint at all if you GAC things and use version redirection or policy files. But this is the way it works.
A colleague researched this more thoroughly than I’m describing here (Dan Woolstencroft) but after a lot of searching and an email conversation with Tariq, we came to the conclusion that we should not version web parts. We leave the version at Version 1.0.0.0.
This leaves you with a dilemma what is the version number of your part. I came up with a way to do this, it’s not perfect as only those who can view the tool pane for that web part can see the More >
Web Part Base
Aug 11th
If you are developing web parts then you probably find you are doing the same thing over and over, how many times have you coded the GetToolParts routine ? How many times have you coded it differently ? Many times and hardly any retrospectively. How many common routines do you have in your web parts relating solely to webparts.
If the answer is lots you need a new spangly web part base class.
Consider writing a base class for you web parts. I have done this and it does a variety of tasks. Initially it only did the GetToolParts routine and a new AddToolPart Routine (I needed someway to add custom tool parts when I used them).
As time went by the class grew. It now implements a common way of web part versioning (I will discuss this later) it also has routines to determine SPS areas so in your web part you need just type this.ContextIsSPS or from the webpart you can get the current area by calling this.CurrentSPSArea.
I later added routines to ensure webparts are only placed in Areas, not on Team Sites, or web parts that are only allowed on the Home page not anywhere else, this forces content managers More >