Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Robert J. Bullock 386 posts 405 karma points
    May 14, 2013 @ 03:03
    Robert J. Bullock
    0

    Umbraco 6 Custom Macro Param Type Broken

    Note sure what's up, but after upgrading to Umbraco 6 my custom macro param type won't render. Here's the code for the param type... 
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.UI.WebControls;
    using umbraco.interfaces;
    
    public class NewsletterPicker : DropDownList, IMacroGuiRendering
        {
            public bool ShowCaption
            {
                get
                {
                    return true;
                }
            }
    
            public string Value
            {
                get
                {
                    return this.SelectedValue;
                }
                set
                {
                    this.SelectedValue = value;
                }
            }
    
            protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);
                if (this.Items.Count != 0)
                    return;
                this.Items.Add(new ListItem("Men's Health", "G0071"));
                this.Items.Add(new ListItem("Women's Health", "G0072"));
                this.Items.Add(new ListItem("Heart Care", "G0073"));
                this.Items.Add(new ListItem("Breast Health", "G0074"));
                this.Items.Add(new ListItem("Diabetes Health", "G0075"));
                this.Items.Add(new ListItem("For Your Child", "G0076"));
                this.Items.Add(new ListItem("Mind and Body", "G0077"));
            }
        }
    
    

    Updated the macro parameter types database with my assembly name and class name, but still no luck.

  • Robert J. Bullock 386 posts 405 karma points
    May 14, 2013 @ 04:39
    Robert J. Bullock
    0

    Got it figured out... had to do with the way my namespaces were setup.

  • Robert Dougan 48 posts 154 karma points
    May 23, 2013 @ 15:52
    Robert Dougan
    0

    Hi Robert,

    I'm having a similar issue.

    Can you tell me what your solution was?

    Thanks,

    Robert

  • Robert J. Bullock 386 posts 405 karma points
    May 23, 2013 @ 18:34
    Robert J. Bullock
    0

    Yes, it has to do with the way you register the control in the database. Here's my control code:

    namespace LourdesWeb.macroParams
    {
        public class NewsletterPicker : DropDownList, IMacroGuiRendering
        {
    
            protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);
                if (this.Items.Count == 0)
                {
                  ....
                }
            }
    
            #region IMacroGuiRendering Members
    
            public bool ShowCaption
            {
                get
                {
                    return true;
                }
            }
    
            public string Value
            {
                get
                {
                    return this.SelectedValue;
                }
                set
                {
                    this.SelectedValue = value;
                }
            }
            #endregion
    
        }
    }
    

    And in the Umbraco cmsMacroPropertyType table:

    idmacroPropertyTypeAliasmacroPropertyTypeRenderAssemblymacroPropertyTypeRenderTypemacroPropertyTypeBaseType

    26newsletterPickerLourdesWebmacroParams.NewsletterPickerString

    So, the thing is, you only put the last part of your namespace for some reason for the macroPropertyTypeRenderType field. Weird, but true. ;-)

  • Robert J. Bullock 386 posts 405 karma points
    May 23, 2013 @ 18:35
    Robert J. Bullock
    0

    Oppps, that data didn't render well... 

    id macroPropertyTypeAlias  macroPropertyTypeRenderAssembly macroPropertyTypeRenderType macroPropertyTypeBaseType
    26  newsletterPicker    LourdesWeb  macroParams.NewsletterPicker    String
    
  • Robert Dougan 48 posts 154 karma points
    May 28, 2013 @ 13:28
    Robert Dougan
    0

    Thanks for this Robert.

    I think I have everything set up in the same way but I still can't get the property to work.

    Very frustrating!

    Robert

  • Robert Dougan 48 posts 154 karma points
    May 28, 2013 @ 13:48
    Robert Dougan
    0

    Ah, Finally solved it!

    I was putting the name of my assembly into the macroPropertyTypeRenderAssembly, it should be the namespace apparently! Then in macroPropertyTypeRenderType is should be the type name (without any assembly name or namespace).

    I think your solution didn't work for me because of the way I had set up my assembly in the first place.

    Very confusing.

Please Sign in or register to post replies

Write your reply to:

Draft