我创建了用户控件。它有 string[]
公共(public)属性(property)(可能是 List<string>
或其他)。在声明此用户控件的实例时,我想支持在 aspx 代码中定义此属性。像这样的东西:
<uc1:MyControl ID="MyControl1" runat="server">
<MyStringCollectionProperty>
<string>My String 1</string>
<string>My String 2</string>
<string>My String 3</string>
</MyStringCollectionProperty>
</uc1:MyControl>
如何让它发挥作用?谢谢...
最佳答案
您实际上可以使用 TypeConverterAttribute 来指定转换器类(在本例中为 StringArrayConverter)。
关于ASP.NET 用户控件列表/集合/数组属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3016931/