Annoying Control problem
-
With help from minhpc_bk, I succeeded in creating a WebControl that didn't delete child controls, and serialized the child controls on the page. But now I'm having troubles getting the control to render properly on the page in design time. It seems like the child tags aren't parsed when I'm rendering. This is the code (the important parts at least.)
/// /// A control for putting the child elements inside the inner cell in a table. /// [ToolboxData("<{0}:GreyBox runat='server'>")] [PersistChildren(true)] [ParseChildren(true, "BoxChildren")] [DesignerAttribute(typeof(GreyBoxDesigner), typeof(IDesigner))] [ControlBuilderAttribute(typeof(GreyBoxControlBuilder)) ] public class GreyBox : System.Web.UI.WebControls.WebControl, INamingContainer { #region MEMBER VARIABLES /// /// The collection of child controls. /// protected ControlCollection boxChildren; #endregion #region CONSTRUCTORS /// /// Creates a new instance of this control. /// public GreyBox(): base("table") { this.boxChildren = new ControlCollection(this); this.CssClass = "greybox"; } #endregion #region PROPERTIES /// /// The collection of child controls. /// [Bindable(true), Category("Appearance")] [PersistenceMode(PersistenceMode.InnerDefaultProperty)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ControlCollection BoxChildren { get { return boxChildren; } } #endregion // -- rendering methods and such is left out in this example!... }
When the RenderDesignTimeHtml method is invoked in the designer, the collection BoxChildren is empty. "After all it's just text at the end of the day. - Colin Davies "For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
-
With help from minhpc_bk, I succeeded in creating a WebControl that didn't delete child controls, and serialized the child controls on the page. But now I'm having troubles getting the control to render properly on the page in design time. It seems like the child tags aren't parsed when I'm rendering. This is the code (the important parts at least.)
/// /// A control for putting the child elements inside the inner cell in a table. /// [ToolboxData("<{0}:GreyBox runat='server'>")] [PersistChildren(true)] [ParseChildren(true, "BoxChildren")] [DesignerAttribute(typeof(GreyBoxDesigner), typeof(IDesigner))] [ControlBuilderAttribute(typeof(GreyBoxControlBuilder)) ] public class GreyBox : System.Web.UI.WebControls.WebControl, INamingContainer { #region MEMBER VARIABLES /// /// The collection of child controls. /// protected ControlCollection boxChildren; #endregion #region CONSTRUCTORS /// /// Creates a new instance of this control. /// public GreyBox(): base("table") { this.boxChildren = new ControlCollection(this); this.CssClass = "greybox"; } #endregion #region PROPERTIES /// /// The collection of child controls. /// [Bindable(true), Category("Appearance")] [PersistenceMode(PersistenceMode.InnerDefaultProperty)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ControlCollection BoxChildren { get { return boxChildren; } } #endregion // -- rendering methods and such is left out in this example!... }
When the RenderDesignTimeHtml method is invoked in the designer, the collection BoxChildren is empty. "After all it's just text at the end of the day. - Colin Davies "For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus