Method 1:
To dynamically Add a control to "maintain", load it in page_init instead of page_load.
C # code
Protected override void oninit (eventargs e) {try {// load the control base here. oninit (E);} catch (exception myex) {myhelper. showexceptionmeessage (myex);} finally {}}
Method 2:
Protected void page_load (Object sender, eventargs e) {If (! Ispostback) {loadtextbox () ;}} protected override void loadviewstate (Object savedstate) {base. loadviewstate (savedstate); If (isdynamicloadcontrol) {loadtextbox () ;}} private void loadtextbox () {for (INT I = 0; I <10; I ++) {textbox input = new Textbox (); input. id = "input" + I. tostring (); this. form1.controls. add (input);} isdynamicloadcontrol = true;} public bool isdynamicloadcontrol {get {object Dynamic = viewstate ["isdynamicloadcontrol"]; return dynamic = NULL? False: true;} set {viewstate ["isdynamicloadcontrol"] = value ;}}
Textbox TB = This. findcontrol ("input0") as textbox; clientscript. registerstartupscript (this. getType (), "", String. format ("<SCRIPT> alert ('{0}') </SCRIPT>", TB. text ));
Finally, you can perform the test: