How to get control in ASP.NET PreInit event? Pointers are null and FindControl method returns null.
I am using master and content pages. Markup of the content page looks like this:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentBody" runat="server">
<asp:Table ID="Table1" runat="server" Width="100%">
.....
</asp:Table>
</asp:Content>
And code like this:
private void Page_PreInit(object sender, EventArgs e)
{
Control table = this.FindControl("Table1");
//table is null here
}
So table still is null after this.FindControl("Table1"). NamingContainer of the page is null too. What am I doing wrong?
UPDATE I have to use this event to create controls. As said in the ASP.NET Page Life Cycle Overview this event should be used for dynamic control creation. I need to create a list of links in my table. May be there is another way to do it?