Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
SDK Documentation
General Reference
Custom Field Types
 Field Rendering Controls
Community Content
In this section
Statistics Annotations (0)
This page is specific to
The 2007 product release

Other versions are also available for the following:
Field Rendering Controls

A rendering control class can be used, in conjunction with a rendering template, to render your custom fields in New mode or Edit mode. (Such classes can also used to render a field in Display mode, but it is more common to use a RenderPattern defined in a field definition to render fields in Display mode.)

A rendering control class must inherit from BaseFieldControl or one of the classes in Windows SharePoint Services that derive from it. This class is compiled into the same assembly as the custom field class.

We recommend that you use the following naming convention when you create custom field classes that are derived, directly or indirectly, from the BaseFieldControl class:

field_type_name FieldControl

,-- for example, TargetDateFieldControl or RegularExpressionFieldControl. (The BaseFieldControl-derived classes that ship with Windows SharePoint Services 3.0 were created before this naming convention was determined and they follow the pattern field_type_nameField such as the DateTimeField.)

An object instantiating a rendering control holds, in its Field property, a reference to the field object that it renders. The latter holds a reference to its rendering control in its FieldRenderingControl property. As these reciprocal references suggest, the two objects are partners. The SPField-derived object handles interaction with the content database, while the BaseFieldControl-derived rendering control handles interaction with users and the rendering of the field in the UI.

The Rendering Template

Every rendering control has at least one rendering template associated with it. A RenderingTemplate object is defined as a RenderingTemplate element in an .ascx file in the folder C:\program files\common files\microsoft shared\web server extensions\12\template\controltemplates. The rendering template is referenced by its ID value in the rendering control object's TemplateName property.

Note Note:

BaseFieldControl inherits, from TemplateBasedControl, members that enable it to be linked to multiple rendering templates and to switch between them based on the rendering context.

For more information about rendering templates, see Field Rendering Templates.

The CreateChildControls Method

A rendering control class overrides the CreateChildControls method that it inherits from Control. Since the rendering template is doing most of the rendering work, the CreateChildControls method has much less to do than it would in a classic ASP.NET control class. Typically, it provides only a final polish to the child controls. For example, it might assign a default value to a child control in New mode or assign the field's current value to a child control in Edit mode. It is not likely that your overrides of CreateChildControls will contain a lot of new operators creating child controls (which may come as a surprise if you have a background in ASP.NET programming).

Data validation logic is sometimes included in CreateChildControls. For more information about custom field data validation, see Custom Field Data Validation.

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker