Hi guys,
I had developed a server control which acts as a container (user can add any control inside the server control).

[DefaultProperty("Text")]
    [Designer(typeof(ContainerControlDesigner))]
    [ParseChildren(false)]
    [ControlBuilderAttribute(typeof(SampleControlBuilder))]
    [ToolboxData("<{0}:Sample  runat="server"></{0}:Sample>")]
    public class Sample: WebControl, INamingContainer
    {
protected override void CreateChildControls()
        {
            System.Collections.IEnumerator myEnumerator = items.GetEnumerator();
            while (myEnumerator.MoveNext())
                this.Controls.Add((TextBox)myEnumerator.Current);
        }

        protected override void AddParsedSubObject(Object obj)
        {
            if (obj is TextBox)
            {
                items.Add(obj);
            }
        }
    }
public class SampleControlBuilder : ControlBuilder
    {
        public override Type GetChildControlType(String tagName,
                                            IDictionary attributes)
        {
            if (String.Compare(tagName, "myitem", true) == 0)
            {
                return typeof(TextBox);
            }
            return null;
        }
    }

    public class SampleContainerControlDesigner : ContainerControlDesigner
    {
        public override bool AllowResize
        {
            get { return false; }
        }

        private Style _style = null;
ublic override string FrameCaption
        {
            get
            {
                return "Dynamic Page Loader";
            }
        }

        public override Style FrameStyle
        {
            get
            {
                if (_style == null)
                {
                    _style = new Style();
                    _style.Font.Name = "Verdana";
                    _style.Font.Size = new FontUnit("XSmall");
                    _style.BackColor = Color.LightBlue;
                    _style.ForeColor = Color.Black;
                }

                return _style;
            }
        }
    }

When the server control droped:

<cc1:Sample ID="Sample"  runat="server" />

When the user add some control to the server control:

<cc1:Sample ID="Sample"  runat="server" >
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</cc1:Sample>

Now, what I want is to add some controls (without user add anything) within the server control tags just after the user had dropped the server control from toolbox into the webform asp.

How can I do this?????

Best regards :)

Member Avatar for LastMitch

Now, what I want is to add some controls (without user add anything) within the server control tags just after the user had dropped the server control from toolbox into the webform asp.

@Rasool Ahmed

What MVC are you using?

Read this:

http://msdn.microsoft.com/en-us/library/sbz9etab%28v=vs.100%29.aspx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.