<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Hosting Open Forum</title><link>http://forums.asp.net/158.aspx</link><description>General discussions concerning ASP.NET in a Windows Hosting environment</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Composite Control Design Time Behavior</title><link>http://forums.asp.net/thread/1502282.aspx</link><pubDate>Tue, 19 Dec 2006 18:29:49 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1502282</guid><dc:creator>jorgegrajales090</dc:creator><author>jorgegrajales090</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1502282.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=158&amp;PostID=1502282</wfw:commentRss><description>&lt;p&gt;I have a problem with the composite control design time behavior... &lt;/p&gt;&lt;p&gt;I have a class that inherits from compositeControl and in the
CreateChildControls method I add a label with a custom text value. But
I want set the label style from a skin file. In the browser all works fine, but in design time not appears the style that I set in the skin file. And @Page Theme="" and StyleSheetTheme="" is not the solution, because with the other controls like the label, the theme applies very well.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Some of you has the same problem? How I can solution that.&lt;/p&gt;&lt;p&gt;&amp;nbsp;Regards..&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Composite Control Design Time Behavior</title><link>http://forums.asp.net/thread/1398411.aspx</link><pubDate>Wed, 13 Sep 2006 20:42:14 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1398411</guid><dc:creator>rrahlf</dc:creator><author>rrahlf</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1398411.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=158&amp;PostID=1398411</wfw:commentRss><description>&lt;p&gt;Here&amp;#39;s a list of common design-time attributes:&lt;/p&gt;&lt;p&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/a19191fh.aspx"&gt;http://msdn2.microsoft.com/en-us/library/a19191fh.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/tk67c2t8.aspx"&gt;http://msdn2.microsoft.com/en-us/library/tk67c2t8.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;and the whole namespace:&lt;/p&gt;&lt;p&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/system.componentmodel.aspx"&gt;http://msdn2.microsoft.com/en-us/library/system.componentmodel.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;RefreshProperties is particularly interesting in relation to CompositeControl, but I don&amp;#39;t think it&amp;#39;s the&amp;nbsp;entire solution.&lt;/p&gt;</description></item><item><title>Re: Composite Control Design Time Behavior</title><link>http://forums.asp.net/thread/1398181.aspx</link><pubDate>Wed, 13 Sep 2006 18:02:14 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1398181</guid><dc:creator>rrahlf</dc:creator><author>rrahlf</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1398181.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=158&amp;PostID=1398181</wfw:commentRss><description>&lt;p&gt;Just after writing the post above, I came across a &lt;a href="http://infinitiesloop.blogspot.com/2006/02/composite-controls-made-easy.html"&gt;blog post&lt;/a&gt; very much in the same discussion by Dave Reed [Infinity88].&lt;/p&gt;&lt;p&gt;I&amp;#39;m going to call &amp;quot;store the property value to the viewstate and set the child control property in CreateChildControls&amp;quot; method the &amp;quot;ViewState Method&amp;quot;.&amp;nbsp; The &amp;quot;expose child control properties directly and use EnsureChildControls in Init or in each property accessor&amp;quot; method the &amp;quot;Expose Method&amp;quot;.&lt;/p&gt;&lt;p&gt;Dave&amp;nbsp;seems to be thinking along the same lines as I am -&amp;nbsp;that the ViewState Method of exposing child control properties is inefficient, causing duplicates - but Dave brings up another good point: the&amp;nbsp;ViewState Method&amp;nbsp;fails once CreateChildControls is called at run-time.&amp;nbsp; Read Dave&amp;#39;s blog for details.&amp;nbsp; &lt;/p&gt;&lt;p&gt;Comments on Dave&amp;#39;s blog by&amp;nbsp;Stefaan Rillaert and Simone Busoli also hit upon the same design-time issue as I had with the Expose Method,&amp;nbsp;it doesn&amp;#39;t work at design-time.&amp;nbsp; Both methods&amp;nbsp;are trying to overcome the shortcomings of the other;&amp;nbsp;the ViewState&amp;nbsp;Method&amp;nbsp;works better at design-time, the&amp;nbsp;Expose Method works better&amp;nbsp;at run-time.&amp;nbsp; So what&amp;#39;s the &amp;quot;holy-grail&amp;quot; solution?&lt;/p&gt;&lt;p&gt;Busoli mentions in Reed&amp;#39;s blog that using the Expose Method and overriding RecreateChildControls as &lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;protected override void&lt;/span&gt; RecreateChildControls()
{
EnsureChildControls();
}&lt;/pre&gt;&lt;p&gt;&amp;nbsp;solved the Expose Method&amp;#39;s state-loss-at-design-time issue in his case, but that method isn&amp;#39;t going to work for a control like the new .NET 2.0 LoginControl which renders different templates based on a property value.&amp;nbsp; In that case, simply calling EnsureChildControls wouldn&amp;#39;t clear the control tree and recreate the alternate template as desired.&amp;nbsp; My implementation of RecreateChildControls I listed in my last post will aslo fail in this case, since the view state cannot be restored if the owning controls are missing from the control tree.&amp;nbsp; &lt;/p&gt;&lt;p&gt;It feels like the CompositeControlDesigner&amp;#39;s method of calling RecreateChildControls whenever any property is changed in design-mode is a hammer too large for the nail.&amp;nbsp; I can&amp;#39;t think of a catch-all solution, but perhaps there isn&amp;#39;t one.&amp;nbsp; Some design-time property changes are going to require the control tree to be rebuilt, some will only require a redraw.&amp;nbsp; The answer may be to create a PropertyAttribute that indicates whether a property change at design time should generate a rebuild or a redraw.&amp;nbsp; The default action would be a redraw, but special properties like the one that changes the template for the LoginControl would be marked as &amp;quot;cause design-time rebuild&amp;quot;.&amp;nbsp; &lt;/p&gt;&lt;p&gt;Are there any resources that offer a good examination of design-time attribute classes?&amp;nbsp; We&amp;#39;ve probably all seen Description and Category, but I&amp;#39;ve just recently run into RefreshProperties and NotifyParentPropertyAttribute which are still a bit of a mystery.&amp;nbsp; There may already be a property attribute that accomplishes what I&amp;#39;m suggesting, but I&amp;#39;m not sure where to look.&lt;/p&gt;</description></item><item><title>Re: Composite Control Design Time Behavior</title><link>http://forums.asp.net/thread/1398119.aspx</link><pubDate>Wed, 13 Sep 2006 17:10:51 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1398119</guid><dc:creator>rrahlf</dc:creator><author>rrahlf</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1398119.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=158&amp;PostID=1398119</wfw:commentRss><description>&lt;p&gt;I realize this post is over a year behind the conversation, but I&amp;#39;ll give it a shot anyway.&lt;/p&gt;&lt;p&gt;I&amp;#39;ve also recently run into this issue, and found the same solution thanks in part to an &lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnaspp/html/ASPNETContDev.asp#aspnetcontdev_topic5"&gt;article by Dino Esposito&lt;/a&gt;.&amp;nbsp; However, in all the examples I&amp;#39;ve seen on the web and in Dino&amp;#39;s source code, I notice that the view state of the child controls is never disabled.&amp;nbsp; Wouldn&amp;#39;t this create dupicate entries for properties in the viewstate?&amp;nbsp; &lt;/p&gt;&lt;p&gt;It seems to me that directly exposing the properties of child controls - rather than maintaining state in the parent control - is more in-line with the idea of why we should create a composite control in the first place; leverage the power of the child controls and let them&amp;nbsp;handle their own state, postback, rendering ect.&amp;nbsp; It seems that the ICompositeControlDesignerAccessor and CompositeControlDesigner are cripling this methodology for run-time by requiring the CompositeControl to handle CreateChildControls at any time during the design-time.&amp;nbsp; I&amp;nbsp;do see the requirement&amp;nbsp;for rebuilding the control tree at design time for a control which changes it&amp;#39;s control tree dramaticly based on a property or template.&amp;nbsp; However, in&amp;nbsp;simple&amp;nbsp;cases such as Alex Rosen&amp;#39;s above, shouldn&amp;#39;t the the Designer request that the control be re-rendered, not rebuilt?&lt;/p&gt;&lt;p&gt;That being the case, does anyone find fault with leaving the control as Alex wrote it in his original post, thus eliminating duplicates in the view state at run-time, but overriding the ICompositeControlDesignerAccessor.RebuildControls() method to maintain the control&amp;#39;s viewstate across rebuilds?&lt;/p&gt;&lt;pre class="coloredcode"&gt;    &lt;span class="kwd"&gt;Protected Overrides Sub&lt;/span&gt; RecreateChildControls()
        &lt;span class="kwd"&gt;Dim&lt;/span&gt; c &lt;span class="kwd"&gt;As Object&lt;/span&gt; = &lt;span class="kwd"&gt;Me&lt;/span&gt;.SaveControlState()
        &lt;span class="kwd"&gt;Dim&lt;/span&gt; v &lt;span class="kwd"&gt;As Object&lt;/span&gt; = &lt;span class="kwd"&gt;Me&lt;/span&gt;.SaveViewState()

        &lt;span class="kwd"&gt;MyBase&lt;/span&gt;.RecreateChildControls()

        &lt;span class="kwd"&gt;Me&lt;/span&gt;.LoadControlState(c)
        &lt;span class="kwd"&gt;Me&lt;/span&gt;.LoadViewState(v)
    &lt;span class="kwd"&gt;End Sub&lt;/span&gt;&lt;/pre&gt;&amp;nbsp;</description></item><item><title>Re: Composite Control Design Time Behavior</title><link>http://forums.asp.net/thread/829148.aspx</link><pubDate>Wed, 16 Feb 2005 01:27:51 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:829148</guid><dc:creator>SimonCal</dc:creator><author>SimonCal</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/829148.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=158&amp;PostID=829148</wfw:commentRss><description>The current CompositeControl base class exposes an accessor that is used to recreate the child controls in the designer scenario. This performs a forceable recreate of the collection. However, when this occurs, the issue is that the proeprty sets that you have delegated to the child controls are lost immediately.
&lt;br /&gt;

&lt;br /&gt;
The design pattern for composite control therefore was such that it assumes a parent needs the ability at any time to recreatechildcontrols and therefore needs to hold onto state itself rather than delegating to the children. This will be true, if for example you create a composite control tthat exposes templates too.
&lt;br /&gt;

&lt;br /&gt;
Hope this helps.</description></item><item><title>Re: Composite Control Design Time Behavior</title><link>http://forums.asp.net/thread/792593.aspx</link><pubDate>Fri, 07 Jan 2005 15:32:30 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:792593</guid><dc:creator>alexrosen</dc:creator><author>alexrosen</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/792593.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=158&amp;PostID=792593</wfw:commentRss><description>Frederik,
&lt;br /&gt;

&lt;br /&gt;
Thanks so much for that simple and elegant solution. I knew there had to be an easy way but everything I was reading was steering me away from what should have been more obvious.
&lt;br /&gt;

&lt;br /&gt;
Thanks!
&lt;br /&gt;

&lt;br /&gt;
- Alex Rosen</description></item><item><title>Re: Composite Control Design Time Behavior</title><link>http://forums.asp.net/thread/792568.aspx</link><pubDate>Fri, 07 Jan 2005 15:18:44 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:792568</guid><dc:creator>Fredrik N</dc:creator><author>Fredrik N</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/792568.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=158&amp;PostID=792568</wfw:commentRss><description>Remove the EnsureChildControls() form the Text property, set the TextBox control within the constructor. The following example works fine:
&lt;br /&gt;

&lt;br /&gt;
&lt;pre&gt;
&lt;br /&gt;
namespace TestControls
&lt;br /&gt;
{
&lt;br /&gt;
    [DefaultProperty(&amp;quot;Text&amp;quot;)]
&lt;br /&gt;
    [ToolboxData(&amp;quot;&amp;lt;{0}:TestControl runat=server&amp;gt;&amp;lt;/{0}:TestControl&amp;gt;&amp;quot;)]
&lt;br /&gt;
    public class TestControl : CompositeControl
&lt;br /&gt;
    {
&lt;br /&gt;
        private TextBox createdControl;
&lt;br /&gt;

&lt;br /&gt;
        public TestControl()
&lt;br /&gt;
        {
&lt;br /&gt;
            createdControl = new TextBox();
&lt;br /&gt;
        }
&lt;br /&gt;
        
&lt;br /&gt;
        [Browsable(true), Category(&amp;quot;Misc&amp;quot;)]
&lt;br /&gt;
        public String Text
&lt;br /&gt;
        {
&lt;br /&gt;
            get
&lt;br /&gt;
            {
&lt;br /&gt;
                return createdControl.Text;
&lt;br /&gt;
            }
&lt;br /&gt;
            set
&lt;br /&gt;
            {
&lt;br /&gt;
                createdControl.Text = value;
&lt;br /&gt;
            }
&lt;br /&gt;
        }
&lt;br /&gt;

&lt;br /&gt;
        protected override void CreateChildControls()
&lt;br /&gt;
        {
&lt;br /&gt;
            Controls.Add(createdControl);
&lt;br /&gt;
        }
&lt;br /&gt;
    }
&lt;br /&gt;
}
&lt;br /&gt;
&lt;/pre&gt;</description></item><item><title>Composite Control Design Time Behavior</title><link>http://forums.asp.net/thread/792555.aspx</link><pubDate>Fri, 07 Jan 2005 15:10:20 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:792555</guid><dc:creator>alexrosen</dc:creator><author>alexrosen</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/792555.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=158&amp;PostID=792555</wfw:commentRss><description>I am running into trouble using controls that inherit from the CompositeControl class at design time. Here is a simple example control:
&lt;br /&gt;

&lt;br /&gt;
namespace TestControls
&lt;br /&gt;
{
&lt;br /&gt;
	[DefaultProperty(&amp;quot;Text&amp;quot;)]
&lt;br /&gt;
	[ToolboxData(&amp;quot;&amp;lt;{0}:TestControl runat=server&amp;gt;&amp;lt;/{0}:TestControl&amp;gt;&amp;quot;)]
&lt;br /&gt;
	public class TestControl : CompositeControl
&lt;br /&gt;
	{
&lt;br /&gt;
		private TextBox createdControl;
&lt;br /&gt;

&lt;br /&gt;
		[Browsable(true), Category(&amp;quot;Misc&amp;quot;)]
&lt;br /&gt;
		public String Text
&lt;br /&gt;
		{
&lt;br /&gt;
			get
&lt;br /&gt;
			{
&lt;br /&gt;
				EnsureChildControls();
&lt;br /&gt;
				return createdControl.Text;
&lt;br /&gt;
			}
&lt;br /&gt;
			set
&lt;br /&gt;
			{
&lt;br /&gt;
				EnsureChildControls();
&lt;br /&gt;
				createdControl.Text = value;
&lt;br /&gt;
			}
&lt;br /&gt;
		}
&lt;br /&gt;

&lt;br /&gt;
		protected override void CreateChildControls()
&lt;br /&gt;
		{
&lt;br /&gt;
			createdControl = new TextBox();
&lt;br /&gt;
			Controls.Add(createdControl);
&lt;br /&gt;
		}
&lt;br /&gt;
	}
&lt;br /&gt;
}
&lt;br /&gt;

&lt;br /&gt;
The control runs fine. However, at design time it does not show the value I set for its Text property whether I set it in the aspx page's source view or design view. In design view if I type a value for Text into the property grid it is immediately erased although whatever I type does show up in source view and therefore at run time.
&lt;br /&gt;

&lt;br /&gt;
I have run the debugger on an instance of VS 2005 to see what is going on at design time. What I find is that CreateChildControls executes twice at design time. The first time happens as a result of the ControlBuilder initializing the properties which leads to a call to EnsureChildControls and then the overridden CreateChildControls. The second time is when the CompositeControlDesigner's GetDesignTimeHTML method calls its own CreateChildControls which calls RecreateChildControls (from ICompositeControlDesignerAccessor). That method calls EnsureChildControls but apparently with the flag that indicates whether the controls have been created reset so the controls are created again. However, their properties are not set after this second creation.
&lt;br /&gt;

&lt;br /&gt;
I have been reading the Kothari/Datye book and implemented a rudimentary designer that overrode the GetDesignTimeHTML method. Although I haven't traced that version, it seems that the call to the base class's method causes the same issue. How can I avoid this double creation during design time or, if it is necessary, get the properties that were set during the first creation copied onto the controls that are created during the second creation? Of course I would hope there is a generic solution that allows me to use the same designer on several different simple composite controls.
&lt;br /&gt;

&lt;br /&gt;
Thanks,
&lt;br /&gt;
- Alex Rosen</description></item></channel></rss>