共用方式為


Default Element (Field Types Property Schema)

Applies to: SharePoint Foundation 2010

Important

This topic describes markup that was used in an obsolete method of rendering custom field type properties. It is provided solely to assist with the debugging of custom field type properties developed against earlier versions of SharePoint Foundation. For information about the recommended method, Custom Field Type Property Rendering.

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

How to: Create a Custom Field Class

Custom Field Type Property Rendering

How to: Create a Custom Field Type Definition