Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Annoying Control problem

Annoying Control problem

Scheduled Pinned Locked Moved ASP.NET
designhelpsysadmintutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jan larsen
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • J jan larsen

      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

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi Jan, From what I see, in order for the control to render properly at design time, you can try to comment out the PersistChildren attribute at the control declaration:

      //[PersistChildren(true)]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups