User Control Code :
Code webcontrols
Copy code The Code is as follows: using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. Web;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Namespace xuyuanwang. mycontrol
{
Public partial class lablexuyuan: system. Web. UI. usercontrol
{
String A = "OK ";
Public String
{
Set
{
A = value;
}
Get
{
Return;
}
}
Protected void page_load (Object sender, eventargs E)
{
Label1.text =;
}
}
}
ASPX page code:
Code copy Code the code is as follows: public partial class webform1: system. web. UI. page
{< br> protected void page_load (Object sender, eventargs e)
{< BR >}< br> protected void button#click (Object sender, eventargs E)
{< br> mycontrol. lablexuyuan CTL = (mycontrol. lablexuyuan) page. loadcontrol ("mycontrol/lablexuyuan. ascx ");
CTL. A = This. textbox1.text;
arraylist list = addl (CTL);
for (INT I = 0; I {< br> mycontrol. lablexuyuan ctl2 = (mycontrol. lablexuyuan) list [I];
This. updatepanel1.contenttemplatecontainer. controls. add (ctl2);
}< BR >}< br> private system. collections. arraylist addl (mycontrol. lablexuyuan L)
{< br> system. collections. arraylist list = NULL;
If (session ["A"]! = NULL)
{< br> List = (arraylist) session ["A"];
}< br> else
{< br> List = new arraylist ();
}< br> list. add (l);
session ["A"] = List;
return list;
}