Problem: design time links between custom server controls.



I have a problem which has been touched on in this forum but I have not been
able to establish from those posts what the trick is.

I have two ASP.NET 2.0 custom server controls MyControl1 and MyControl2.

Class MyControl2 has a public property of type MyControl1 which at design
time I expect to provide a drop down in the property inspector showing a list
of all MyControl1 instances.

here's the code:

public class MyControl1: Control
{
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<p>MyControl1</p>");
}
}

public class MyControl2 : Control
{
private MyControl1 _FirstControl;
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<p>MyControl2</p>");
}
public MyControl1 Control1
{
get{return _FirstControl;}
set{_FirstControl = value;}
}
}

If I place a MyControl1 and a MyControl2 on a new web page, I indeed get a
populated drop down on the Control1 property of the MyControl2 instance.

However if i change to source view then back again to design view, I get an
error in MyControl2 stating : "MyControl2_1:Cannot create an object of type
'MyClassLibrary.MyControl1' from its string representation 'MyControl1_1' for
the 'Control1' property."

I suspect that I have to provide some plumming in order for the designer to
rehydrate the attribute Control1="MyControl1_1" in the ASPX source view back
into the property as displayed in the designer.

Any ideas ?

Regards,
Dave Prentice

.