开发者

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

开发者 https://www.devze.com 2022-12-15 22:46 出处:网络
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

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

精彩评论

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