Dela via


How to: Create an Editor Control for a Field Type Property

Applies to: SharePoint Foundation 2010

An editor control for the variable properties of a field type can be used, as an alternative to a PropertySchema Element (Field Types), to render the properties of the field on the New Site Column, Change Site Column, Create Column, and Change Column pages. See Custom Field Type Property Rendering for an overview of the two options and a discussion of when to use each method.

Creating an Editor Control

An editor control is defined in an .ascx file in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\ControlTemplates and in a code-behind file that are compiled into the same assembly as the custom field class. In addition to rendering the properties of the field, the editor control supports column creators who are setting those properties with special functions, such as complicated computational logic, look-up of values from data sources, and custom data validation.

Note   We recommend that you name your editor control classes using the following naming convention:

field_type_nameFieldEditor

for example, TargetDateFieldEditor or RegularExpressionFieldEditor. In line with this convention, your .ascx file will be named field_type_nameFieldEditor.ascx and will inherit from the code-behind class field_type_nameFieldEditor.

The IFieldEditor Interface

To act as a field editor user control, the code-behind class must do the following:

The IFieldEditor interface includes the following property and methods. Click the name of each to learn more about how to implement it.

  • DisplayAsNewSection   Use this property to specify whether or not you want the control to be displayed in the Additional Column Settings section on the New Site Column, Change Site Column, Create Column, and Change Column pages, or alone in a new section.

  • OnSaveChange   Use this method to validate and save a column-creator's or column-editor's changes to the field (column) properties.

  • InitializeWithField   Use this method to initialize the editor control with either default values or the current property values of the field (column).

See Also

Concepts

Custom Field Types

How to: Create a Custom Field Class

How to: Create a Custom Field Type Definition