Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3221882
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:55:39+00:00 2026-05-17T15:55:39+00:00

I’m trying to add a dynamically expandable property to a composite control that I

  • 0

I’m trying to add a dynamically expandable property to a composite control that I can drop on the designer surface. I’ve tried this with a String Array, a List, and an ArrayList. All with similar results. I’m missing something and I don’t know what. Here is what I think is the relevant code:

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), 
    NotifyParentProperty(true),
    PersistenceMode(PersistenceMode.InnerProperty)]
    public String[] AccessLevels
    {
        get
        {
            String[] s = (String[])ViewState["AccessLevels"];
            return s;
        }

        set
        {
            ViewState["AccessLevels"] = value;
        }
    }

The control compiles fine and I can drop it on my designer surface. It gives me a property in the “Properties” window on Visual Studio 2008 called “+AccessLevels” with a value of “String[] Array” and an elipsis […] next to it. If I click the elipsis it opens up an editor where I can insert properties one line at a time. If I click the little plus symbol next to the “AccessLevels” property, it shows the properties that I entered and each has a number next to it, indicating the index of the array. Great! But when I do this, regardless of what values I enter as properties, the following HTML is autogenerated by the designer.

    <cc2:HBAdmin ID="HBAdmin1" runat="server">
        <AccessLevels>
        <system.string></system.string>
        <system.string></system.string>
        <system.string></system.string>
        </AccessLevels>
    </cc2:HBAdmin>

HBAdmin is the name of my control, and the cc2 namespace is correct. The problem is the tags. There should be a value in there right? I also get intellisense for the <AccessLevels> tag telling me “Content is not allowed between the opening and closing tags for element ‘AccessLevels'”, and also a validation error on the <system.string> tag telling me “Element ‘System.String’ is not supported. Then if I try to view the page with the control in the browser (after editing the properties in the design window that results in the markup above) I get the following error on the line with the opening tag for the control:

“Array creation must have array size or array initializer”

I only get this error when I try to edit the properties in the properties window of the designer. I can populate the property with values in the constructor and the page with the control will load in the browser and work fine, and the values show up fine in the properties window of the design surface and I can use the values throughout the control, but I can’t edit them in the properties window. If I try to add one I get the same symptoms as described above.

I feel like I’m probably just missing some sort of attribute or declaration or something. Please help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:55:39+00:00Added an answer on May 17, 2026 at 3:55 pm

    Try something like:

    Usage:

    <cc:SomeClass >
     <CustomLavel key="" value="" />
     <CustomLavel key="" value="" />
     <CustomLavel key="" value="" />
    </cc:SomeClass>
    
    
    public class SomeClass: Control, INamingContainer
    {
               private Collection<CustomLabel> _customLabelList;
    
               protected override void AddParsedSubObject(object obj)
            {
                base.AddParsedSubObject(obj);
    
                if (obj is CustomLabel)
                {
                    _customLabelList.Add((CustomLabel)obj);
                    return;
                }
            }
    
    [Category("Behavior")]
            [Description("The fields collection")]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]    
            [PersistenceMode(PersistenceMode.InnerDefaultProperty)]
            [DefaultValue(null), MergableProperty(false), Bindable(false)]
            public Collection<CustomLabel> CustomLabelList
            {
                get
                {
                    return _customLabelList;
                }
            }
    }
    
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class CustomLabel
    {
        private string _key;
        private string _value;
    
        public CustomLabel()
            : this(string.Empty, string.Empty)
        {
        }
    
        public CustomLabel(string key, string value)
        {
            _key = key;
            _value = value;
        }
    
    
        [Category("Behavior")]
        [DefaultValue("")]
        [Description("Key")]
        [NotifyParentProperty(true)]
        public string Key
        {
            get
            {
                return _key;
            }
            set
            {
                _key = value;
            }
        }
    
        [Category("Behavior")]
        [DefaultValue("")]
        [Description("Value")]
        [NotifyParentProperty(true)]
        public string Value
        {
            get
            {
                return _value;
            }
            set
            {
                _value = value;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.