BaseFieldControl.DisplayTemplate Property

Gets or sets an object that can be used to control the rendering of the BaseFieldControl object in display mode; that is, when it is not on a New or Edit form.

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

<TemplateContainerAttribute(GetType(FormComponent))> _
Public Property DisplayTemplate As ITemplate
    Get
    Set

Dim instance As BaseFieldControl
Dim value As ITemplate

value = instance.DisplayTemplate

instance.DisplayTemplate = value
[TemplateContainerAttribute(typeof(FormComponent))]
public ITemplate DisplayTemplate { get; set; }

Property Value

Type: System.Web.UI.ITemplate
An ITemplate that controls the rendering of the BaseFieldControl object.

Remarks

For most field controls, this property is a null reference (Nothing in Visual Basic) because rendering in Display mode is easier when it is configured with a RenderPattern in the field definition. But if your field is sufficiently complex or requires special data access or processing before its value can be rendered, you might prefer to use an ITemplate.

With the default implementation, if DisplayTemplate has not been explicitly set but DisplayTemplateName is not a null reference (Nothing in Visual Basic), DisplayTemplate returns the ITemplate that is named by DisplayTemplateName. But if DisplayTemplate has been set, its default getter ignores the value of DisplayTemplateName.

Notes to Inheritors

With their default implementations, it is possible for DisplayTemplate to be set to a template other than the one that is named by DisplayTemplateName. Hence, with the default implementations, when your code sets DisplayTemplate, it should also set DisplayTemplateName to the name of the same ITemplate. Similarly, when your code sets DisplayTemplateName, it should also set DisplayTemplate to the same ITemplate. If you do not enforce logical consistency in this way and the two properties have inconsistent values at render time, DisplayTemplate determines the template that is used for rendering the field.

If you decide to use a template for rendering in Display mode, you can have your override of the getter of ControlTemplate return DisplayTemplate when the control mode is Display. Alternatively, your override of CreateChildControls can set TemplateName to DisplayTemplateName when the control mode is Display.

See Also

Reference

BaseFieldControl Class

BaseFieldControl Members

Microsoft.SharePoint.WebControls Namespace

Other Resources

Patterns of Custom Field Rendering

Custom Field Types

Walkthrough: Creating a Custom Field Type