用户控件传值

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

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);
}
posted @ 2011-01-10 22:01  China2008  阅读(223)  评论(0编辑  收藏  举报