ASP.NET 用户控件列表/集合/数组属性

标签 asp.net list user-controls properties

我创建了用户控件。它有 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/

相关文章:

asp.net - 如何使用 EXTJS 实现 ASP.NET MVC 身份验证成员资格提供程序?

python - 将几个变量 append 到 Python 中的列表

c# - 如何检查特定字符串是否不存在于 c# 的列表中?

asp.net - 在用户控件中修改页眉

c# - 动态用户控件更改 - WPF

c# - 如何在 ASP.NET Core 1.0 中使用 UseStaticFiles

asp.net - 绑定(bind)时如何禁用列表框控件中的某些项目

asp.net-mvc - 仅显示模型中的某些值

asp.net页面定位问题

c# - DataList 列分布