I currently have a client who is using SharePoint in a rather unconventional way; although they want to use the publishing features of SharePoint, they wanted to provide their own front-end user interface for collecting information from the user, after which they will use the SharePoint object model to stuff those collected values into the underlying fields of the list item.

Because of this requirement, my clients have created an application page which pops up in a modal dialog window. That application page has a form which users can fill out. When they click the “save” button, the underlying code will create or update a publishing page in the Pages library. The client still wanted to use the Rich Image, Rich Link, and Rich HTML editor controls, but they needed these controls to not be directly bound to an underlying field (since the editor controls do not exist on a publishing page that is directly bound to underlying fields.)

This article will walk you through the process of getting these controls working on an application page.

All three of these controls are included in the Microsoft.SharePoint.Publishing assembly, so to get this working, you first need to add the following directive to the top of your application markup (.aspx) page:

<%@Register TagPrefix="CMS" Assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.Publishing.WebControls"%>

To add a Rich Image control to your page, add the RichImageSelector control to your markup, like this:

<CMS:RichImageSelector ID="richImageSelector" runat="server" />

To add a Rich Link control to your page, add the RichLinkSelector control to your page, like this:

<CMS:RichLinkSelector ID="richLinkSelector" runat="server" />

And finally, to add a Rich HTML control your page, add the HtmlEditor control, like this:

<CMS:HtmlEditor ID="htmlEditor" runat="server" />

In your code behind, retrieving the values for the Image control and the Link control are fairly straight-forward.

Say you have a RichImageSelector control on your page, and it has an ID of richImageSelector. If you had a list item with a column of type ImageField called “Page Image”, you could easy update the list item’s column value like this:

li["Page Image"] = richImageSelector.Value;

You can do the same with a control of type RichLinkSelector that populates a LinkField called “Page Link”:

li["Page Link"] = richLinkSelector.Value;

Getting the HTML Editor wired up takes a little bit more work. Before I explain how it works, I want to give you a little background.