<p>I have a custom control that I need to use in another custom control. I have written all code at server side (no HTML). Can anyone tell me how to write below line of code in code behind using <code>htmlTextWriter</code> and how to register this control or how to write custom control within another where html is written from code behind?</p>
<pre><code>&lt;cc2:test id=&quot;test1&quot; runat=&quot;server&quot; marqueedirection=&quot;left&quot; marqueeheight=&quot;25&quot;
            marqueewidth=&quot;725&quot; ShowImage=&quot;False&quot; ShowTitle=&quot;False&quot; ShowUrlUnderLine=&quot;True&quot;&gt;&lt;/cc2:test
</code></pre>

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" />
```
```