开发者

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 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜