vs2005 Web Custom Control

  • Thread starter Thread starter Amelyan
  • Start date Start date
A

Amelyan

I need to create web custom control that can contain any type of control as
a child (similar to asp:Panel control). However, when I try to include
children in my web control on aspx page, it says 'Content is not allowed
between the opening and closing tags for element'.

Does any one have an example of how to build this simple web custom control?

Thanks,
 
You must create a library (so it is a Custom Sever Control and not a User
Control)

public class SlideNavMenu : Control
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
}
protected override void Render(HtmlTextWriter output)
{
this.CreateChildControls();
for (int i = 0; i < this.Controls.Count; i++)
{
this.Controls.RenderControl(output);
}
}
}
 
Back
Top