I have a control called PromoArea.ascx. This is the code for the front end
<div class="vh-right-rail-promoarea">
<asp:PlaceHolder ID="DynamicControl1" runat="server"></asp:PlaceHolder>
</div>
I have registered this web part in pages.config and put it on my template
<site:PromoArea ID="PromoArea" runat="server"/>
However, when I am trying to add control to it dynamically, the placeHolder returns null. This is my code behind
PlaceHolder ph =
(PlaceHolder)this.Page.FindControl("DynamicControl1");
ph.Controls.Add("controlName");
ph returns null. I read somewhere that if you want to add a control inside a placeHolder, you have to find a place holder on page first, cast it, and then add control to it. So why is my place holder control return null then?