views:

1836

answers:

1

I'm trying to create a custom field type in SharePoint (WSS 3.0) that has custom properties. I have created my fldtypes*.xml file based on the SDK docs and this blog post and it seems to render fine and I can retrieve the custom property values inside my code. My problem is that after the initial field creation, if I go back to the list settings page and click on my newly added field, the form shows my custom properties with some value that I'm not providing it. For example, if my custom property's display name is "My Custom Prop" then the value in its textbox will be "My Custom Prop field value".

My question is this: how can I properly show the actual string values of my custom property types in these textboxes?

Here's my fldtypes*.xml file:

<?xml version="1.0" encoding="utf-8"?>
<FieldTypes>
  <FieldType>
    <Field Name="TypeName">MyCustomField</Field>
    <Field Name="TypeDisplayName">My Custom Field</Field>
    <Field Name="TypeShortDescription">MyCustomField</Field>
    <Field Name="ParentType">Text</Field>
    <Field Name="UserCreatable">TRUE</Field>
    <Field Name="FieldTypeClass">MyCustomField.CustomFields.MyCustomField, MyCustomField, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d772gbab82fe6996</Field>
    <PropertySchema>
      <Fields>
        <Field Name="MyCustomProp" DisplayName="My Custom Prop" Type="Text" MaxLength="50" DisplaySize="30" />
      </Fields>
    </PropertySchema>
  </FieldType>
</FieldTypes>

And here's the code for my field type class:

public class MyCustomField : SPFieldText
{
    private string propval;

    public MyCustomField(SPFieldCollection fields, string fieldName)
     : base(fields, fieldName)
    {
    }

    public MyCustomField(SPFieldCollection fields, string typeName, string displayName)
     : base(fields, typeName, displayName)
    {           
    }

    public override void Update()
    {
     // I can see any updated value here
     propval = GetCustomProperty("MyCustomProp") as string;
     base.Update();
    }

    public override Type FieldValueType
    {
     get { return typeof (string); }
    }

}

What can I do to see the correct custom property values in my "Change Column" page (FldEditEx.aspx) in my SharePoint app?

+1  A: 

There is a well known issue with saving and retrieving custom properties on a custom field type. Here is a direct link to the work around.

btw, some of the comments on the post purport the same problem.

Jason