回答済み Help needed with Writing properties for a custom field

  • Wednesday, June 20, 2012 1:04 PM
     
     

    Hello Forum Readers,

    In an attempt to make sense of it all here I am baffled about getting things started.

    Environment - MOSS 2007
    IDE - VS 2008
    Project Type - Empty Project
    Template - Field Control
    Files --
    customfield.field.vb
    customfield.fieldcontrol.vb

    Scenario
    I am trying to write a very simple cascading dropdownlist (yes i know plenty exist out there) but I want to learn how to make custom fields in MOSS 2007. Using the environment and IDE mentioned above inside the FieldControl.vb I can use CreateChildControls to add functionality to the custom column all well and good. I added a Drop down list with selected index changed event all working fine. HOWEVER

    Question
    How and where do I add the properties for my custom field so that they appear in 'Additional Settings for Column' section so users can enter some useful things related to this custom field

    Situation
    Completely Lost; from what I can gather there are two ways
    - Edit xml file to edit property schema (which I find cumbersome process) I also need little logic from properties so xml really is not what I want
    - Use .ascx user control to render properties - where to add this in my VS08 project - lost

    - Or is there any other way- perhaps customfield.field.vb file where I can write properties programmatically.

    Please suggest your experiences and practices and point me towards right direction.

    Thank you for your time.


    Operation completed successfully. ========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========

All Replies

  • Wednesday, June 20, 2012 2:06 PM
     
     

    hi

    you need to create custom field editor - special control which inherits IFieldEditor. It is different from field control. Here is example how to do it: Creating a Custom Editor Control Using IFieldEditor Interface. It is for SP2010, but I think it will be suitable for SP2007 as well.


    Blog - http://sadomovalex.blogspot.com
    CAML via C# - http://camlex.codeplex.com

  • Wednesday, June 20, 2012 4:08 PM
     
     

    Hi,

    Thanks for responding. To be absolutely honest with you this link does provide to me a way of creating properties for custom field but since these are MOSS2010 and not strictly MOSS2007.

    For example taken from the link you sent -

    "

    1. In the Add New Item dialog box, in the Installed Templates tree, click SharePoint, and then click 2010.

    2. In the Templates box, select a SharePoint User Control, and name the .ascx file InterestCalculatorEditor.ascx. Click Add.

      Visual Studio automatically adds the file to the SharePoint solution manifest and sets it to be deployed to %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\ControlTemplates. It also adds the assembly to the manifest and sets it to be deployed to the global assembly cache (GAC).

    "

    Does not apply to My environment since I don't have sharepoint 2010 so Add New Item step is not achievable

    I am struggling to understand why can't I create a property for custom field using Visual Studio 2008, Empty Project, Field Control Template for Moss 2007 site. I am sure there is a way but I will be welcoming more response to my query. 

    Many thanks for your reply, I really appreciate it.


    Operation completed successfully. ========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========

  • Thursday, June 21, 2012 9:13 AM
     
     Answered
    if transition from SP2010 is hard, then you may search for examples for SP2007, e.g. this Creating a Windows SharePoint Services 3.0 Custom Field by Using the EntityPicker. It also has example of custom field editor.

    Blog - http://sadomovalex.blogspot.com
    CAML via C# - http://camlex.codeplex.com

    • Marked As Answer by .Net Frenzy Friday, June 22, 2012 10:23 AM
    •  
  • Friday, June 22, 2012 10:18 AM
     
     Answered

    Hi,

    Thank you so much for your support. Actually, I crossed this article

    http://msdn.microsoft.com/en-us/magazine/dd727508.aspx

    Which points out at the bottom that you can edit fldtypes_FieldName.xml file to insert your custom properties. These properties are then outputted on the create column page and render out in 'Additional column settings' section. Having said that, the popular datacogs Cascade dropdown custom field project - they have created their own (LIKE you mentioned) customer user control inheriting IFieldEditor and which can then be called in the same fldtypes_FieldName.xml file. This would be ideal if you want any interaction with the properties like button click populate dropdownlist on postback etc. The actual field control itself which is presented on the form should sit in the 'ControlTemplates' folder of your project and this is the render of the field control (dropdownlist, button, textbox, label, etc). I suppose I was confused a little and also didnot do enough home work before setting out to do this. I suppose that is what learning is, hit and trial.

    Thank you for sharing this tip with me. Marking this as answer.


    Operation completed successfully. ========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========

    • Marked As Answer by .Net Frenzy Friday, June 22, 2012 10:23 AM
    •