【问题标题】:call user control and pass custom property with allowed values调用用户控件并使用允许的值传递自定义属性
【发布时间】:2015-10-19 10:04:42
【问题描述】:

我想在我的一个 aspx 页面中调用一个用户控件 (ascx),并将一个带有允许的预定义值列表的自定义属性传递给它。 示例:

<uc:MyCustomControl runat="server" CustomProperty="One|Two|Three" />

{One, Two, Three} 应该出现在 Visual Studio 智能下拉列表中,类似于 IsVisible 属性的“Treu|False”值。

【问题讨论】:

  • 将 CustomProperty 定义为枚举!!

标签: c# properties controls


【解决方案1】:

在您的控件上使用枚举:

public enum CustomPropertyOptions
{
     One,
     Two,
     Three
}

public CustomPropertyOptions CustomProperty
{
     get; set;
}

【讨论】:

  • 如果它解决了您的问题,请考虑将此标记为答案。
  • 我试过了,但我没有 15 分,这是将回答标记为答案的资格。
猜你喜欢
  • 2013-01-14
  • 1970-01-01
  • 2011-02-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多