How To: overcome glitches with the standard field controls shipped with MOSS 2007

Some of our field controls shipped with MOSS show a quite ugly behaviour as they add an extra &nbsp; entry after the field. Means an extra space.

This is especially ugly for the RichImageField control as it prevents two images to show up right beside each other. This article shows that this is actually a long known issue. But this article only shows a workaround which can be compared with the approach we used in CMS 2001 before we had custom placeholder controls: to hide the control in published mode, to read the content and then to modify it in the way we want to have it.

An approach in CMS 2002 would have been to create a custom placeholder for this. So only one single change and you can benefit from this anywhere on your site.

A similar approach can easily be implemented using a custom field control in MOSS.

A field control that would fix the problem discussed in this article would look like this:

using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Web; using System.Web.UI; using Microsoft.SharePoint.Publishing.WebControls;

Thanks for the tip. My team have started evaluating MOSS as a WCM platform and we’ve run into issues re accessibility and poor markup (tables being used instead of CSS, spacers, etc) when using the standard controls so this technique will come in very handy. Do you know if there are plans to provide web standards-friendly controls in future (e.g. via service pack or separate download)?

Oen question on RichImageFields: Is it possible to have a custom page layout with multiple PageImages on it?? I’ve tried many times, today, but couldn’t get it to work.

FieldName was set to PublishingPageImage, ID was set to something sifferent for each instance.

Page ‘renders’ correctly in Sharepoint Designer, and when edititing the page in Sharepoint I get to see the placeholders and I can set an image to it, but When I save, all Image-fields show the exect same image, regardless of how I set them…

first you need to create a content type to be used by your page layout. The page layout is just the rendering window for the content type. For each field control you add you need to have an individual column in the content type.