all groups > asp.net building controls > may 2004 >
You're in the

asp.net building controls

group:

Composite Control Designer


Composite Control Designer Alexander Popov
5/26/2004 12:10:06 PM
asp.net building controls:
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?

Re: Composite Control Designer Teemu Keiski
5/26/2004 8:25:00 PM
Hi,

additionally specify the proeprty with NotifyParentProperty(true) attribute.
Does that help at all?

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke



[quoted text, click to view]

Re: Composite Control Designer BMukes
5/28/2004 8:29:46 AM
Please take a look at the Server Control Collection Properties Solutions,
Problems MVP Advice Requested post.
Or
Go to
http://users.adelphia.net/~brianpclab/ServerControlCollectionIssues.htm
.. At the web site you can download source code that will probably get you
further along with your problem.
Brian
[quoted text, click to view]

Re: Composite Control Designer LucaP
6/4/2004 4:25:23 PM
"Alexander Popov" <Alexander@quantum.ru> ha scritto nel messaggio
news:OubnggvQEHA.3300@TK2MSFTNGP09.phx.gbl...
Now I want to have ability fill control with same structure
[quoted text, click to view]

I solved using ParseChildren(false).
If you set it to true, the nested elements are used as properties.
If you set it to false, the nested elements are used as child controls
(that's what you want...).
Bye.

AddThis Social Bookmark Button