Custom elements in ASP.NET with custom child-elements

后端 未结 3 605
我寻月下人不归
我寻月下人不归 2021-01-31 11:53

I know that it is possible to define custom tags in ASP.NET with User Controls. But as far as I know you can only add attributes to these controls. I would like to be able to em

3条回答
  •  攒了一身酷
    2021-01-31 12:12

    It is certainly possible. For your example the classes would look like:

    [ParseChildren(true)]
    class MyGraph : WebControl {
        List _colors = new List();
        [PersistenceMode(PersistenceMode.InnerProperty)]
        public List Colors {
            get { return _colors; }
        }
    }
    
    class Color {
        public string Value { get; set; }
    }
    

    And the actual markup would be:

    
       
         
         
       
    
    

提交回复
热议问题