Default Element (Field Types Property Schema)

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Represents the default value of a property of a custom field type.

<Default>
</Default>

Attributes

None

Child Elements

None

Parent Elements

Field Element (Field Types)

Remarks

See PropertySchema Element (Field Types) for a description of this element in context.

Example

The following example defines a property schema for a custom field type called "RegularExpressionMatch." The schema declares a field that can be used by column creators when they create a column based on the field type. The purpose of the field is to enable a column creator to set a different regular expression for each column that is based on the RegularExpressionMatch field type.

The DisplayName and an editable Text field appear in the Additional Column Settings section on the New Site Column page and the Create Column page. The MaxLength attribute sets the maximum length, in characters, of the regular expression, and DisplaySize sets the size of the field that holds the MaxLength attribute. Users can scroll within the field to see the rest of the regular expression if it is longer than what appears in the DisplaySize field.

In the code example below, the Default element for the property is

^(\d{3})\d{3}-\d{4}$

because this pattern matches American telephone numbers and in this example the developer knows that his field will most frequently be used to create columns that hold American telephone numbers. When users create a column that is based on a custom field type, and the New Site Column and Create Column pages initially open, this property value appears in a text box, where it can then be changed by the column creator. Note that the code example below has been edited for clarity.

<FieldType>
  <Field Name="TypeName">RegularExpressionMatch</Field>
  …
  <PropertySchema>
    <Fields>
      <Field Name="RegularExpression" 
             DisplayName="Regular Expression To Match" 
             MaxLength="500" 
             DisplaySize="100" 
             Type="Text">
        <Default>^(\d{3})\d{3}-\d{4}$</Default>
      </Field>
    </Fields>
  </PropertySchema>
  …
</FieldType>

See Also

Concepts

Custom Field Types

Custom Field Classes

Custom Field Type Property Rendering

Custom Field Type Definition