User Control Code:
Code WebControls
Copy codeThe 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 codeThe Code is as follows:
Public partial class WebForm1: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
}
Protected void button#click (object sender, EventArgs e)
{
MyControl. Lablexuyuan ctl = (myControl. Lablexuyuan) Page. LoadControl ("myControl/Lablexuyuan. ascx ");
Ctl. A = this. TextBox1.Text;
ArrayList list = addl (ctl );
For (int I = 0; I <list. Count; I ++)
{
MyControl. Lablexuyuan ctl2 = (myControl. Lablexuyuan) list [I];
This. UpdatePanel1.ContentTemplateContainer. Controls. Add (ctl2 );
}
}
Private System. Collections. ArrayList addl (myControl. Lablexuyuan l)
{
System. Collections. ArrayList list = null;
If (Session ["a"]! = Null)
{
List = (ArrayList) Session ["a"];
}
Else
{
List = new ArrayList ();
}
List. Add (l );
Session ["a"] = list;
Return list;
}