In this example for loading a user control dynamically, how do I declare "TimeDisplay"? Can this be done in the code behind, or is it done in the ascx page? This is an example from a book, I guess there are assumptions made as to where the code files are located relative to one another?
protected void Page_Load(object sender, EventArgs e)
{ TimeDisplay ctrl = (TimeDisplay)Page.LoadControl("TimeDisplay.ascx");
PlaceHolder1.Controls.Add(ctrl);
}
You do need to add a reference to the control in your aspx page: