Mike Cole
Mike Cole

Reputation: 14723

Adding user control to ASP.NET webform, but don't want it to declare itself in designer file

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

Answers (3)

rick schott
rick schott

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

Mike Cole
Mike Cole

Reputation: 14723

The answer to my issue was to develop the form outside of Visual Studio.

Upvotes: 0

ram
ram

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

Related Questions