vs2005 Web Custom Control

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,
 
D

Daniel Fisher\(lennybacon\)

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);
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top