代码之家  ›  专栏  ›  技术社区  ›  Ed James

C#自定义控件:将内部内容用作文本字段

  •  1
  • Ed James  · 技术社区  · 16 年前

    我正在创建一个自定义控件,希望获取标记中的所有内容,并将其用作控件上的字符串文本字段:

    <custom:control ID="C" runat="server">This text should go into the text property</custom:control>
    

    有人知道如何做到这一点吗?我已经在我的文本字段上尝试了以下属性(从文本控件复制),但似乎不起作用!

        [DefaultValue(""), Bindable(true), Localizable(true)]
    
    1 回复  |  直到 16 年前
        1
  •  0
  •   internet man    16 年前

    在控制类上:

    [ParseChildren(true, "TextPropertyNameHere")]
    [PersistChildren(false)]
    

    在控件的属性上:

    [PersistenceMode(PersistenceMode.InnerDefaultProperty)]
    

    或者类似的事情。

    推荐文章