views:

83

answers:

2
+1  A: 

First, build a simple custom web control:

namespace My.Controls
{
    public class InnerControl : Control
    {
        protected override void Render(HtmlTextWriter writer)
        {
            writer.WriteLine("<h1>Inner Control</h1>");
        }
    }
}

Then build your second web control that contains and renders the first:

namespace My.Controls
{
    public class OuterControl : Control
    {
        protected override void Render(HtmlTextWriter writer)
        {
            writer.WriteLine("<h1>Outer Control</h1>");
            InnerControl innerControl = new InnerControl();
            innerControl.RenderControl(writer);
        }
    }
}

Finally, register the control on your page, and display it:

<%@ Register TagPrefix="c" Namespace="My.Controls" %>
<c:OuterControl runat="server" />
cxfx
A: 

Thankx it works.. i was missing only one line--

innerControl.RenderControl(writer);