Add a field editor for the TargetTo field type (SPFieldTargetTo) in Sharepoint 2010

This took me forever to google “just right”

I was looking for a Field Editor control in SharePoint 2010 that would let me edit a TargetTo Field Type right on my Publishing Page Layout.

It was not in the usual place (Microsoft.SharePoint.WebControls), it’s actually housed in the Microsoft.Office.Server.UserProfiles Assembly in Microsoft.Office.Server.UserProfiles.dll.

Here’s what you need to add to your page layout:

<%@ Register TagPrefix=”OfficeWebControls” Namespace=”Microsoft.Office.Server.WebControls.FieldTypes” Assembly=”Microsoft.Office.Server.UserProfiles, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>

and

<OfficeWebControls:SPFieldTargetToControl ID=”AudienceEdit” runat=”server” FieldName=”Audience” ControlMode=”Edit” />

I was able to piece this together from this sharepoint 2007 blog: http://sites.google.com/site/netsourcecode/sharepointdevelopmentblog/adding-audience-targeting-to-your-publishing-page and MSDN: http://msdn.microsoft.com/en-us/library/microsoft.office.server.webcontrols.fieldtypes.spfieldtargettocontrol.aspx

Post a comment or leave a trackback: Trackback URL.

Comments

  • Rikard Uppström  On January 9, 2012 at 1:42 pm

    Well done!
    Hard to believe this is so undocumented!

  • mari  On May 22, 2012 at 9:23 am

    This is a great post! I am developing a custom page layout for creating a new item in SharePoint. I added this control on my asp.net page (not a dataview) and it is not showing. Do you know what is causing the problem?

Leave a comment