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
2008-11-18 07:36:54