Copied to clipboard

Flag this post as spam?

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


  • Nitish Raina 9 posts 39 karma points
    Jan 27, 2012 @ 13:44
    Nitish Raina
    0

    Need "DropDownList" in Macros parameter type.

    Hello all, 

    I am using Umbraco v 4.0.2.1 with .Net framework 3.5. I've a User Control and made a Macro for the same and have added all the properties of the User Control, which are now listed in Parameter.  

     

    As you can see I've NoOfQuotes and the type is number it shows a text box. I want  user to provide No of Quotes not more than 3 but since the control is textbox it can provide more than 3. I want to know how can I overcome with this problem. 

     

     

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jan 27, 2012 @ 15:48
    Ismail Mayat
    0

    You need to create a custom macro property type see http://www.richardsoeteman.net/2010/01/04/CreateACustomMacroParameterType.aspx on how to do this.

    Regards

    Ismial 

  • Nitish Raina 9 posts 39 karma points
    Jan 28, 2012 @ 05:45
    Nitish Raina
    0

    Hi, Thanks for your reply. I visited the link that you provided and followed the steps. Now, the problem arises I've DropDownList with value 1 and 2. if I select 2 and click ok it's not retaining it again shows 1. What should I do to make this retain it's value.

  • Michael Lykke 12 posts 75 karma points
    Dec 17, 2016 @ 12:21
    Michael Lykke
    0

    While working on an older installation (4.11.10) I ran in to this issue so I thought I'd just share my findings.

    And it seems that the set method of Value is called before the items are added. Therefore, you need to add the items before calling this.SelectedValue = value;.

    I added a private method to call in the constructor and in the set method.

    public string Value
    {
        get
        {
            return this.SelectedValue;
        }
        set
        {
            AddItems();
            this.SelectedValue = value;
        }
    }
    private bool ItemsAdded
    {
        get
        {
            return this.Items.Count > 0;
        }
    }
    private void AddItems()
    {
        if (!ItemsAdded)
        {
            this.Items.Add(new ListItem("Text 1", "Value1"));
            this.Items.Add(new ListItem("Text 2", "Value2"));
        }
    }
    

    Otherwise, my code is similar to the code on this page: http://www.richardsoeteman.net/2010/01/04/CreateACustomMacroParameterType.aspx

Please Sign in or register to post replies

Write your reply to:

Draft