有两个WEB控件可以用,一个是PlaceHolder,一个是Pannel

解决方案 »

  1.   

    也可以用下面的方法建立自已的容器控件:
    Programmatic composite controls create child controls programmatically. All controls inherit a virtual CreateChildControls method from Control that can be overridden in a derived class. The .NET Framework calls CreateChildControls very early in the control’s lifetime, so it’s the perfect place to instantiate child controls. The following control is the programmatic equivalent of the declarative control presented a few moments ago—the one containing Label controls with the greetings “Hello!” and “Goodbye!”using System.Web.UI;
    using System.Web.UI.WebControls;namespace Wintellect
    {
        public class CompositeControl : Control
        {
            protected override void CreateChildControls () 
            {
                Label label1 = new Label ();
                label1.Text = "Hello!";
                Controls.Add (label1);
                Controls.Add (new LiteralControl ("<br>"));
                Label label2 = new Label ();
                label2.Text = "Goodbye!";
                Controls.Add (label2);
            }
        }
    }
    In its override of CreateChildControls, CompositeControl instantiates the Label controls with new and adds them to its Controls collection with ControlCollection.Add. It also uses a Literal control to insert a <br> element between the Labels.
      

  2.   

    PlaceHolder不可以作为设计阶段的容器
      

  3.   

    jlhdlj():
    谢谢你的回复,我希望在设计阶段便能件控件拖入,而按这种做法只有在运行阶段才可出来!并且不能象Panel那样在设计阶段拖入控件!
      

  4.   

    http://expert.csdn.net/Expert/topic/2213/2213752.xml?temp=.2877313
      

  5.   

    try the code I provided in 
    http://expert.csdn.net/Expert/topic/2213/2213752.xmlit is a container and you shouldn't add controls inside the code, do it in html or drag/drop, since the system doesn't call GetDesigntimeHtml for containers