I added it to the controls collection, it did not help. I looked at maybe 3 dozen threads and found nothing quite like my problem.
Following is the code to a small test program that shows what i mean: I try to use the PostFilterEvents method in the designer to eliminate the 'Disposed' event. To keep things short I attach the designer both to the main class and the subproperty class. If you put the main class (TestControl) on a webpage you will see in the designer that the TestControl's Disposed events misses and the SubControl's event in the expanded events is still visible.
What must i change or add? And when exactly is the designer called (for the main class and the subproperty)?
Ray
[ ParseChildren(false), Designer(typeof(SubControlDesigner)) ]
public class TestControl : System.Web.UI.WebControls.WebControl, INamingContainer
{
private string mstrText;
private Tests.SubControl tsc;
protected override void CreateChildControls() {
tsc = new SubControl();
this.Controls.Add(tsc);
base.CreateChildControls ();
}
[ Description("Test subproperty."),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerProperty) ]
public Tests.SubControl SubControl {
get { return tsc; }
set { tsc = value; }
}
public string TcText {
get { return mstrText; }
set { mstrText = value; }
}
protected override void Render(HtmlTextWriter output) {
output.Write(TcText);
base.Render(output);
}
} //END public class TestControl
[ Designer(typeof(SubControlDesigner)) ]
public class SubControl : System.Web.UI.WebControls.WebControl
{
private string mstrText;
public string ScText {
get { return mstrText; }
set { mstrText = value; }
}
} //END public class SubControl
public class SubControlDesigner : ControlDesigner
{
protected override void PostFilterEvents(System.Collections.IDictionary events) {
events.Remove("Disposed");
base.PostFilterEvents (events);
}
} //END public class SubControlDesigner