If you would like to discuss anything, please contact me via email: Howard.Bayliss@sequence.co.uk

Tuesday, September 13, 2011

SharePoint Inline HTML Editor

One of our clients had very specific requirements for the way in which their editors manage the main body content of a page. Here is some background:

With the previous version of SharePoint (MOSS 2007), page editors could edit page content using a Rich Text editor that sat above the content field. This is shown below:

MOSS RichText Editor

With SharePoint 2010, the Ribbon provides the editing functionality, as shown below:

Ribbon Editor

Even though our client is using SharePoint 2010, they wanted to use the MOSS-style page editor, rather than the Ribbon. This was for a subset of editors, on one specific site.

One way to solve this is to switch the User Interface (UI) version of the site from "4", to "3" e.g. switch from the SharePoint 2010 UI to the MOSS UI. This is done via the SPWeb.UIVersion property.

We didn't want to change the UI version so in the end, the solution was to:

1) Create a custom edit form.
2) Change the control used to edit the page content from SharePoint:FormField to SharePoint:InputFormTextBox

The InputFormTextBox has some properties that allow Rich Text, which are shown below:

<SharePoint:InputFormTextBox TextMode="MultiLine" Rows="6" RichText="true" RichTextMode="Compatible" runat="server" />

Friday, September 9, 2011

SharePoint 0x810200c6 List Validation Failed

We use custom code to create a new Publishing Page:

SPWeb currentWeb = SPContext.Current.Web;

PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(currentWeb);

PublishingPage page = publishingWeb.GetPublishingPages().Add(newPageName, newPageLayout);

This was failing with the error:

<nativehr>0x810200c6</nativehr><nativestack></nativestack>List data validation failed.

The error was caused because the Pages library had validation applied to it, which validated two date fields. The formula for the validation was:

=[Start Date and Time]<[End Date and Time]

When the page was created in code, the validation was fired, which failed because the two date fields are initially empty.

The solution to the problem was to change the validation formula to handle the initial values e.g.

=[Start Date and Time]<=[End Date and Time]

Tuesday, September 6, 2011

SharePoint The document contains invalid utf-8 encoded characters

We used SharePoint to index a website and got the message "The document contains invalid utf-8 encoded characters".

To fix this, modify the target site and replace special characters with their encoded equivalent. For example, replace any £ characters with &pound;. The same is true for ©, which should be replaced with &copy, etc.

Use the W3C validator to identify encoding issues.