form1.Controls.Add(Page.LoadControl("SomeUserControl.ascx"));Hi Viv,
/// <summary> /// Display the Content Control /// </summary> /// <param name="display">AboutDisplayType</param> private void DisplayContent(AboutDisplayType display) { // Create a reference to each control ucAboutHistory historyControl = null; ucAboutChairmansCorner chairControl = null; ucAboutOrgChart chartControl = null; ucAboutBiography bioControl = null; ucAboutChapters chapterControl = null; // Check what controls are in the placeholder foreach (var control in this.holdAboutContent.Controls) { if (control is ucAboutHistory) historyControl = (ucAboutHistory)control; if (control is ucAboutChairmansCorner) chairControl = (ucAboutChairmansCorner)control; if (control is ucAboutOrgChart) chartControl = (ucAboutOrgChart)control; if (control is ucAboutBiography) bioControl = (ucAboutBiography)control; if (control is ucAboutChapters) chapterControl = (ucAboutChapters)control; } // Check if the controls should be displayed or not, otherwise remove them // History Control if (display == AboutDisplayType.History) { if (historyControl == null) { // Create the Control historyControl = (ucAboutHistory)this.CreateContentControl(display); historyControl.ID = "ucHistory"; } this.holdAboutContent.Controls.Add(historyControl); } else { if (historyControl != null) // Shouldn't the control to be removed be "ucHistory"? this.holdAboutContent.Controls.Remove(historyControl); } ... MoreI am sure there is a more generic way to do this but I don't have 50 different possible controls. What is nice about this approach with user controls is I can change the entire content area without navigating to a different page altogether. When you use Ajax it makes for a nicer user experience and I don't have tons of code doing visible true or false on everything. I also have seperate ascx pages that have only what is part of a single control. I like the approach quite well and use this in several sites now. If I change from About page to Resources page for instance then I change pages. I don't try to do 50 different controls on a page. Also in this case I only have one control on the page at a time, but that doesn't have to be; several could be added to the placeholder at a time easy enough as well as literal stuff.