ASP.NET: Add custom control in code behind

I am creating a custom control entirely in a source file (.cs). I added a custom control as a sub control, but it does not render.

Related tags: .NET

Credit: Original Poster

When instantiating the control in the OnInit function, you have to specify the control path in the LoadControl function call.

customControl = (CustomControl)Page.LoadControl("~/CustomControl.ascx");

Rating: 0

Propose a different solution...