Learn how to dynamically add button and events to a panel.
Simple demo dynamic Add Picture button and add Click event
ImageButton jian = new ImageButton ();
Jian. IMAGEURL = "~/picture01.png";
Jian. Click + + new Imageclickeventhandler (Jian_click);
P.controls.add (Jian);
Then ran into the checkbox, thought it should be similar, but wrote the following code did not react
CheckBox Cbox = new checkbox ();
Cbox. Checked = true;
Cbox. Checkedchanged+=cbox_change;
P.controls.add (Cbox);
Look at a lot of resources on the Internet and finally found the reason. This event happened on the server side, and after we clicked the checkbox and did not return the value of the change back to the server, the modifications are as follows:
CheckBox Cbox = new checkbox ();
Cbox. Checked = true;
Cbox. AutoPostBack = true; Added this sentence
Cbox. Checkedchanged+=cbox_change;
P.controls.add (Cbox);