Language preference:

Phase 5 / Select alternative Field Templates

By default, Field Templates are selected for you based on the DataTypeAttribute or property type of the DataField. For example, any string type property loads Text.ascx or Text_Edit.ascx. If it has the DataTypeAttribute(DataType.MultiLine), the same string type will load MultiLine.ascx and MultiLine_Edit.ascx.

Often you want to select an alternative:

  • You created a new Field Template that customizes the original.
  • There are several unique formats from which to choose, like Boolean types have with Boolean.ascx, BooleanLabel.ascx, and BooleanCheckBox.ascx.
  • You want to use a Field Template developed around a third party control.

Each Field Template file must be located in the [web app]\BLD Templates\FieldTemplates folder, or a subfolder. When in a subfolder, it can have the same name as the one in the FieldTemplates folder.

Here are several ways to load a specific Field Template.

  • UIHint property - Specify the file name, omitting the file extension and "_Edit" parts in this property, found on BLDDataField control, BLDField control, and DataFieldInPattern object.
    <des:BLDDataField id="ProductName" runat="Server" DataField="ProductName" UIHint="TitleText" />
    <des:BLDField DataField="ProductName" UIHint="TitleText" />
    <des:DataFieldInPattern DataField="ProductName" UIHint="TitleText" />
  • Defining where to find a Field Template - The [web app]\BLD Templates\FieldTemplate.config file describes the paths searched for a Field Template. If you have created a Field Template in a subfolder that should be used instead of the original, set it up here.
       <path url="FieldTemplates/RadControls/" />
       <path url="FieldTemplates/AJAX Control Toolkit/" enabled="false" />
       <path url="FieldTemplates/" />
       <template name="Text" url="FieldTemplates/CustomTemplates/" modes="edit|insert"/>
  • Themes - You can define a group of Field Templates to handle themes. This way, you can create variations of Field Templates that give a specific appearance and use them by specifying the theme name in the Web Form.
      <theme name="Green" ">
        <skin requested="Text" newname="GreenText" mode="readonly" />
        <skin requested="Boolean" newname="GreenBoolean" mode="readonly" />

In the next topic, you will learn how to set properties on Field Templates to customize them.