A
Alexander Popov
i have following sample Control
[ParseChildren(true)]
[PersistChildren(true)]
public class MyControl: System.Web.UI.Control
{
MyCollection values_ = new MyCollection ();
[PersistenceMode(PersistenceMode.InnerProperty),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public MyCollection Values
{
get
{
return values_;
}
}
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
//...
}
protected override void Render(HtmlTextWriter writer)
{
base.Render (writer);
//...
}
}
//Collection:
public class MyCollection : CollectionBase
{
public MyItem this[int index]
{
get
{
return this.InnerList[index] as MyItem ;
}
}
public MyItem Add(MyItem item)
{
this.InnerList.Add(item);
return item;
}
}
//Item - its NOT control, same as Columns in Datagrid
public class MyItem
{
protected string prop_;
public string Prop
{
get{return prop_;}
set{prop_ = value;}
}
}
it's work Perfect if I fill control by Hand in ASPX :
<cc1:MyControl id=MyControl1 runat="server" >
<Values>
<cc1:MyItem Prop="value1"/>
<cc1:MyItem Prop="value2"/>
<cc1:MyItem Prop="value3"/>
</Values>
</cc1:MyControl>
Now I want to have ability fill control with same structure
in designer.When I click "..." button in property grid on Values row -
Collection Editor is Open and I may do add|remove my Items.But when I click
"OK", in ASPX control stay empty
<cc1:MyControl id=MyControl1 runat="server" >
</cc1:MyControl>
Much more, if control have existing items in aspx view, it's
deleted.Whats wrong?
[ParseChildren(true)]
[PersistChildren(true)]
public class MyControl: System.Web.UI.Control
{
MyCollection values_ = new MyCollection ();
[PersistenceMode(PersistenceMode.InnerProperty),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public MyCollection Values
{
get
{
return values_;
}
}
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
//...
}
protected override void Render(HtmlTextWriter writer)
{
base.Render (writer);
//...
}
}
//Collection:
public class MyCollection : CollectionBase
{
public MyItem this[int index]
{
get
{
return this.InnerList[index] as MyItem ;
}
}
public MyItem Add(MyItem item)
{
this.InnerList.Add(item);
return item;
}
}
//Item - its NOT control, same as Columns in Datagrid
public class MyItem
{
protected string prop_;
public string Prop
{
get{return prop_;}
set{prop_ = value;}
}
}
it's work Perfect if I fill control by Hand in ASPX :
<cc1:MyControl id=MyControl1 runat="server" >
<Values>
<cc1:MyItem Prop="value1"/>
<cc1:MyItem Prop="value2"/>
<cc1:MyItem Prop="value3"/>
</Values>
</cc1:MyControl>
Now I want to have ability fill control with same structure
in designer.When I click "..." button in property grid on Values row -
Collection Editor is Open and I may do add|remove my Items.But when I click
"OK", in ASPX control stay empty
<cc1:MyControl id=MyControl1 runat="server" >
</cc1:MyControl>
Much more, if control have existing items in aspx view, it's
deleted.Whats wrong?