读书人

复合控件 中控件属性的有关问题,求救

发布时间: 2011-12-12 22:59:56 作者: rapoo

复合控件 中控件属性的问题,求救
我想在一个(MyTextBox)控件中加入一下拉列表控件(ItemList)

可将 MyTextBox拖到页面,修改属性保存后到HTML模式看,却没有该属性的HTML代码

哪个高手遇到过这种问题帮指下招,路过的,求求你们,帮顶一脚,代码如下:

MyTextBox:

[ToolboxData( " <{0}:MyTextBox runat=server> </{0}:MyTextBox> ")]
[
ParseChildren(true),
PersistChildren(false),
Themeable(true)
]
public class MyTextBox: WebControl
{
[Bindable(true)]
[Category( "Appearance ")]
[Localizable(true)]
public string Text
{
get
{
String s = (String)ViewState[ "Text "];
return ((s == null)? String.Empty : s);
}

set
{
ViewState[ "Text "] = value;
}
}

ItemList myItemList= new ItemList();
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content),NotifyParentProperty(true),PersistenceMode(PersistenceMode.InnerProperty )]
public ItemList MyItemList
{
get { return this.myItemList; }
}

protected override void RenderContents(HtmlTextWriter output)
{
this.myItemList.RenderControl(output)
}
}


ItemList:


[ToolboxData( " <{0}:ItemList=server> </{0}:ItemList> ")]
[
ParseChildren(true),
PersistChildren(false),
Themeable(true)
]
public class ItemList: WebControl
{
[Bindable(true)]
[Category( "Appearance ")]
[Localizable(true)]

ListItemCollection items= new ListItemCollection();
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content),NotifyParentProperty(true),PersistenceMode(PersistenceMode.InnerProperty )]


public ListItemCollection Items
{
get { return this.items; }
}

protected override void RenderContents(HtmlTextWriter output)
{
foreach(.......)
{
................
}
}
}


ItemList 控件单独使用时正常


[解决办法]
复合控件应该还要实现INamingContainer接口吧?

读书人网 >asp.net

热点推荐