文字内容是不是一个用户控件内允许控件、文字、内容、用户

2023-09-04 09:29:06 作者:①堆②Β説③道④

如何让我的控件包含一个文本里面的标签?

 < UC:我=服务器>文字< / UC:我的>
 

我的控件包含一个复杂的表,我希望把文成小区之一​​。那怎么办?

解决方案

  [PersistChildren(假)]
[ParseChildren(真,文本)]
公共部分类RequiredFieldMarker:用户控件,ITextControl
{
    [类别(设置)
    [PersistenceMode(PersistenceMode.En codedInnerDefaultProperty)
    公共字符串文本
    {
        得到
        {
            返回lblName.Text;
        }
        组
        {
            lblName.Text =价值;
        }
    }
}
 

怎样允许IE运行控件

How to allow my control contains a text inside it's tags?

<uc:My runat="server">Text</uc:My>

My control contains a complex table and I want to put Text into one of cells. How to do that?

解决方案

[PersistChildren(false)]
[ParseChildren(true, "Text")]
public partial class RequiredFieldMarker : UserControl, ITextControl
{
    [Category("Settings")]
    [PersistenceMode(PersistenceMode.EncodedInnerDefaultProperty)]
    public string Text
    {
        get
        {
            return lblName.Text;
        }
        set
        {
            lblName.Text = value;
        }
    }
}