调用用户控件并传递带有允许值的自定义属性
本文关键字:许值 自定义属性 用户 控件 调用 | 更新日期: 2023-09-27 18:18:22
我想调用一个用户控件(ascx)在我的aspx页面之一,并通过一个自定义属性,允许预定义的值列表,给它。例子:
<uc:MyCustomControl runat="server" CustomProperty="One|Two|Three" />
{1,2,3}应该出现在Visual studio智能下拉菜单中,类似于IsVisible属性的"Treu|False"值。
在控件上使用enum:
public enum CustomPropertyOptions
{
One,
Two,
Three
}
public CustomPropertyOptions CustomProperty
{
get; set;
}