How do I make a server control with 2 child controls, AND design support? [modified]
-
I need to make a server control for controlling layout on my page. For various reasons, I don't want to use a master template, and the easiest approach is to make a server control which exposes two child controls. The content on my webpage will be added to these two exposed child controls, which in turn will be rendered surrounding by the layout HTML I need. Everything works fine, except I have no design-time support for it. In other words, I can compile the code, but I have no intellisense on in, which is a major inconvience. I've tried adding the standard attributes to the exposed properties, but I keep getting the "Content is not allowed between the opening and closing tags..." error. Can anyone tell me which attributes I need to add to my control class or its properties in order to get Visual Studio 2005 intellisense to work with the TopContent and BottomContent properties? Thanks! // ###################################### // what the useage should look like : // ###################################### <cc:LayoutTemplate runat="server"> <TopContent> </TopContent> <BottomContent> </BottomContent> </cc:LayoutTemplate> // ###################################### // control definition : // ###################################### public class LayoutTemplate : System.Web.UI.WebControls.WebControl, INamingContainer, IPostBackDataHandler, IPostBackEventHandler { #region FIELDS private Control _topContent; private Control _bottomContent; #endregion #region PROPERTIES [PersistenceMode(PersistenceMode.InnerDefaultProperty), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public Control TopContent { get { return _topContent; } } [PersistenceMode(PersistenceMode.InnerDefaultProperty), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public Control BottomContent; { get { return _bottomContent; } } #endregion #region CTORS public LayoutTemplate( ) : base(HtmlTextWriterTag.Div) { _toptContent = new Control(); _bottomContent = new Control(); this.Con
-
I need to make a server control for controlling layout on my page. For various reasons, I don't want to use a master template, and the easiest approach is to make a server control which exposes two child controls. The content on my webpage will be added to these two exposed child controls, which in turn will be rendered surrounding by the layout HTML I need. Everything works fine, except I have no design-time support for it. In other words, I can compile the code, but I have no intellisense on in, which is a major inconvience. I've tried adding the standard attributes to the exposed properties, but I keep getting the "Content is not allowed between the opening and closing tags..." error. Can anyone tell me which attributes I need to add to my control class or its properties in order to get Visual Studio 2005 intellisense to work with the TopContent and BottomContent properties? Thanks! // ###################################### // what the useage should look like : // ###################################### <cc:LayoutTemplate runat="server"> <TopContent> </TopContent> <BottomContent> </BottomContent> </cc:LayoutTemplate> // ###################################### // control definition : // ###################################### public class LayoutTemplate : System.Web.UI.WebControls.WebControl, INamingContainer, IPostBackDataHandler, IPostBackEventHandler { #region FIELDS private Control _topContent; private Control _bottomContent; #endregion #region PROPERTIES [PersistenceMode(PersistenceMode.InnerDefaultProperty), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public Control TopContent { get { return _topContent; } } [PersistenceMode(PersistenceMode.InnerDefaultProperty), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public Control BottomContent; { get { return _bottomContent; } } #endregion #region CTORS public LayoutTemplate( ) : base(HtmlTextWriterTag.Div) { _toptContent = new Control(); _bottomContent = new Control(); this.Con
Nvm - got a solution on the ever-helpful http://forums.asp.net - changing the exposed control type to PlaceHolder instead of Control fixed it. Good enough solution.