//以下为动态加载用户控件的实现代码,若为静态,应该更简单一点吧
TestCtl.ascx.cs
public class TestCtl : System.Web.UI.UserControl
{
public string Text = " " ;
}
________________________________________________
Test.aspx.cs
protected System.Web.UI.WebControls.PlaceHolder phTestCtl;
private void InitInfo()
{
TestCtl uc =(TestCtl)Page.LoadControl( "TestCtl.ascx ");
uc.Text = "TestStr " ;
this.phTestCtl.Controls.Add(uc);
}
转载于:https://www.cnblogs.com/IsNull/archive/2011/01/10/1932371.html