用户控件传值

//以下为动态加载用户控件的实现代码,若为静态,应该更简单一点吧

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/p/1932371.html