欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

.NET動態(tài)加載用戶控件并傳值的方法

 更新時間:2013年04月02日 09:54:11   作者:  
.NET動態(tài)加載用戶控件并傳值的方法,有需要的朋友可以參考一下

ASPX.CS里的代碼:

復(fù)制代碼 代碼如下:

UserControl uc = (UserControl)LoadControl(actionOne[1].ToString());
uc.GetType().GetProperty("cid").SetValue(uc, cid.ToString(), null);//主要就在這里,這里是添加屬性,并賦值。
uc.GetType().GetProperty("aid").SetValue(uc, id.ToString(), null);
pageAscx.Controls.Add(uc);

以下是ASCX下面的代碼

復(fù)制代碼 代碼如下:

    public string _cid = "0";
    public string _aid = "0";

    public string cid
    {
        get
        {
            return _cid;
        }
        set
        {
            _cid = value;
        }
    }
    public string aid
    {
        get
        {
            return _aid;
        }
        set
        {
            _aid = value;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
    }
}

相關(guān)文章

最新評論