Reputation: 14723
Does anybody know if it's possible to add a user control to a web form in Visual Studio 2008, but to not have its declaration added to the designer file?
Upvotes: 1
Views: 979
Reputation: 21127
Use can use Page.LoadControl, examples in both links:
void Page_Init(object sender, System.EventArgs e)
{
// Instantiate the UserControl object
MyControl myControl1 =
(MyControl)LoadControl("TempControl_Samples1.ascx.cs");
PlaceHolder1.Controls.Add(myControl1);
}
A Good Example of Asp.net LoadControl with multiple parameters
Upvotes: 0
Reputation: 14723
The answer to my issue was to develop the form outside of Visual Studio.
Upvotes: 0
Reputation: 11626
As long as you know the path of the control (either programatically or from DB/config) you can do
Page.Controls.Add("pathToYourControl");
Upvotes: 1