Language preference:

Phase 5 / Applying behaviors to Field Templates

Field Template Behaviors can expand the features of some or all Field Templates without you modifying the Field Template’s code. BLD installs several Behaviors which you can modify to determine the ideal interface.

BLD includes the following Field Template Behavior classes:

  • DependencyFieldTemplateBehavior - If a DESDA.DependencyAttribute exists, it hides or disables the FieldTemplate’s DataControl based on the Dependency’s Condition. With editable Field Templates, it makes the interface interactive by using the FieldStateController from the Peter’s Interactive Pages module.
  • CalculationFieldTemplateBehavior – If the DESDA.CalculationDescriptorAttribute exists, it creates interactive calculations that involve the DataControls of other Field Templates. It uses the CalculationController from Peter's Interactive pages module.
  • HintFieldTemplateBehavior – Adds a hint or tooltip to the Field Template’s DataControl and/or a separate button near the DataControl. You define the source for the hint, such as the DisplayName, Description, or Prompt from metadata, or even actual data from the current Entity object. Interactive Hints are a feature of the Peter's Interactive Pages module.
  • ReadOnlyFieldTemplateBehavior – Changes the user interface of Field Templates in Edit or Insert mode when the DataField is determined to be ReadOnly. (Security restrictions and the ActiveDataField.IsReadOnly property determine this.) This Behavior either disables the DataControl or swaps it with a Label to show the current value.
  • ChangeMonitorFieldTemplateBehavior – The ChangeMonitor, a feature from the Peter’s Interactive Pages module, can monitor edits made to controls and take various actions. When used by BLD, it enables the Save button and displays the Cancel button’s confirmation message only if a change took place. This Behavior lets a Field Template register its DataControl with the ChangeMonitor.

All of these are installed by default. You can modify or remove them by looking at the <behaviors> section of the [web app]\BLD Templates\FieldTemplates.config file.

You can override those global defaults both in the page level and on individual fields. For page-level settings, use the FieldTemplateBehaviors property on the BLDCustomizer control. For field-level settings, use the Behaviors property on BLDDataField control and DataFieldInPattern object.

<des:BLDCustomizer ID="BLDCustomizer1" runat="server" >
   <FieldTemplateBehaviors>
      <des:DependencyFieldTemplateBehavior DependencyName="ForUI" DependencyUI="Hide" />
      <des:ChangeMonitorFieldTemplateBehavior Enabled="false"/>
      <des:ReadOnlyFieldTemplateBehavior Enabled="false"/>
   </FieldTemplateBehaviors>
</des:BLDCustomizer>
<des:BLDDataField id="BirthDate" runat="server" DataField="BirthDate">
  <Behaviors>
      <des:DependencyFieldTemplateBehavior DependencyName="ForUI" DependencyUI="Hide" />
      <des:ChangeMonitorFieldTemplateBehavior Enabled="false"/>
      <des:ReadOnlyFieldTemplateBehavior Enabled="false"/>
  </Behaviors>
</des:BLDDataField>

In the next topic, you will learn how to draw the user's attention to validation errors.