Custom User Control and Friendly Property Item Collection (Like ListBox and ListItems, but with List) on .ASPX

前端 未结 3 1627
野的像风
野的像风 2021-01-19 11:46

I have been wondering a long time how to do a public property for a User Control that work\'s like .NET native Item\'s collection Property (for Example, ListBox and ListItem

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-19 12:47

    You can place a list of your type in the control class and decorate with PersistenceModeAttribute.

    [PersistenceMode(PersistenceMode.InnerProperty)]
    public List ConfigItem { get; set; }
    

    An better example:

    http://am-blog.no-ip.org/BlogEngine/post/2010/04/13/ASP-NET-Custom-Control-with-PersistenceModeInnerProperty-using-Server-Controls.aspx

提交回复
热议问题