Does anybody know if it's possible to add a user control to a web form in Vis开发者_开发技巧ual Studio 2008, but to not have its declaration added to the designer file?
As long as you know the path of the control (either programatically or from DB/config) you can do
Page.Controls.Add("pathToYourControl");
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
The answer to my issue was to develop the form outside of Visual Studio.
精彩评论