0

I follow the instruction from Microsoft to create a custom address field type. I have 3 address: visiting, postal, and invoicing. So I based on the SPFieldMultiColumnValue to implement. Following is the class of CustomAddress

public class CustomAddress : SPFieldMultiColumn
    {
        public CustomAddress(SPFieldCollection fields,
                                   string fieldName)
            : base(fields, fieldName) { }

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

        public override BaseFieldControl FieldRenderingControl
        {
            get
            {
                BaseFieldControl ctr = new AddressFieldControl();
                ctr.FieldName = this.InternalName;
                return ctr;
            }
        }

        public override string GetFieldValueAsHtml(object value)
        {
            string HtmlLineBreak = @"<br />";
            SPFieldMultiColumnValue mcv = new SPFieldMultiColumnValue(value.ToString());            
            string HtmlAddress = "";
            for (int i = 0; i < mcv.Count; i++)
            {
                HtmlAddress += mcv[i].ToString() + HtmlLineBreak;               
            }
            return HtmlAddress;
        }
    }

I set mvc[0] as Visting address, mvc[ 1] as postal address and mvc [2] as invoicing address. Everything works fine for creating and editing item. However, I have issue with viewing item (DisplayForm.aspx). It just shows the visiting address only. Look like it just get the mvc[0] and ignore mvc[ 1] and mvc[ 2]. Please help!

0

Do you have an implementation of fldtypes_whatever.xml? That is where I have the pattern for the DisplayForm.aspx and all the fields seem to show up ok. Should be somewhat appropriate: http://blogs.msdn.com/b/toddca/archive/2009/01/23/customizing-the-rendering-of-a-custom-spfield.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.