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);
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)
{
}
}