Rich Text Editor control in SharePoint 2010


Recently I was presenting for a group of colleagues at Imtech ICT Integrated Solutions about new publishing features in SharePoint 2010. One of the questions that I got was: how can we leverage the Rich Text Editor for anonymous users on Internet-facing websites?

The Scenario

Imagine the following scenario: on your Internet-facing website you want enable your anonymous visitors to post comments or short messages. You want them to be able to use some simple formatting for their messages, but as you don’t want them to use HTML markup, you want to use the Rich Text Editor control that ships with SharePoint.

The Challenge

In Office SharePoint Server 2007 the above requirement was pretty easy to fulfill. What you had to do was to use the following snippet in your control/Web Part:

InputFormTextBox rte = new InputFormTextBox()
{
    TextMode = TextBoxMode.MultiLine,
    RichText = true,
    RichTextMode = SPRichTextMode.Compatible,
    Rows = 10
};

Controls.Add(rte);

and SharePoint would display the Rich Text Editor control on the page:

Telerik Editor in Office SharePoint Server 2007

The situation in SharePoint 2010 looks a bit different though. As you have probably noticed by now, SharePoint 2010 ships with a brand new User Interface including the Ribbon. As a result the Rich Text Editor doesn’t have its own toolbar anymore but uses the options displayed in the Ribbon.

Rich Text Editor in SharePoint 2010: sometimes more is not necessarily what you want

While the new Rich Text Editor has been improved: no doubt about it, is it really something that you would like to use on your Internet-facing site for your anonymous visitors to use? Would you show them the Ribbon? I don’t think so.

The Solution

Although the challenge might seem complex, the solution is very easy – something that you would almost not expect.

What used to work with SharePoint 2007 works still in SharePoint 2010! You can still use exactly the same code snippet to show a Rich Text Editor control with its own toolbar instead the Ribbon:

Custom Web Part with Rich Text Editor control with its own toolbar

Lessons learned? Sometimes it’s just worth trying out some known solutions instead of looking for a new one.

Technorati Tags: SharePoint 2007,SharePoint 2010

Others found also helpful: