CopyCodeThe Code is as follows: // three controls are dynamically generated.
Protected void button#click (Object sender, eventargs E)
{
For (INT I = 0; I <3; I ++)
{
Textbox T = new Textbox ();
T. ID = string. Format ("newtextbox {0}", I );
Panel1.controls. Add (t );
}
Listcontrolsinpanel ();
}
Copy codeThe Code is as follows: // obtain the value of the dynamically generated control
Protected void button3_click (Object sender, eventargs E)
{
String STR = "";
String [] Ak = request. Form. allkeys;
For (INT I = 0; I <request. Form. Count; I ++)
{
// Only the values of the three dynamically generated controls are filtered out.
If (AK [I]. indexof ("new")>-1)
STR + = string. Format ("<li> {0} </LI> <br>", request. Form [I]);
}
Label1.text = STR;
}
// The ID of the newly generated control starts with "new". At the same time, ensure that no control ID on the page contains "new.