Adding a custom control to a page, then adding multiple custom children into that one, null user con

Posted by Rickjaah on Stack Overflow See other posts from Stack Overflow or by Rickjaah
Published on 2010-05-03T18:15:07Z Indexed on 2010/05/03 18:18 UTC
Read the original article Hit count: 323

Filed under:
|
|
|

Hello all,

While nerding my way through the day again. I came across a problem concerning adding children to an already add child control.

I can add the controls, but when trying to use the controls in the added control, they all return null.

This is the method:

protected override CreateChildControls(EventArgs e)
{
    UserControl uControl = LoadControl("~/controls/TwoColumn.ascx");
    PlaceHolder holder = uControl.Controls.FindControl(phrContentMiddle) as PlaceHolder;
    holder.Controls.Add(LoadControl("~/controls/ImageShowControl");
}

When i try to call any type of button/UserControl inside the ImageShowControl.... All return null. Is this something in the Page LifeCycle?

If so, what is the way to go to realize this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET