c# - add more than one control from code behind? -


what want add more 1 control code behind website, know how add 1 control, want add 2 controls @ same time, when click on other button!

here code, add second button!

protected void unnamed2_click(object sender, eventargs e)       {           button b = new button();           (int = 0; < 2; i++)           {               b.id = i.tostring();               b.text = i.tostring();               b.width=250;               b.height = 100;               b.style.add("background-color", "red");              page.form.controls.add(b);            }       } 

the new button() needs in loop... otherwise create 1 instance.

for (int = 0; < 2; i++) {     button b = new button();     b.id = i.tostring();     b.text = i.tostring();     b.width=250;     b.height = 100;     b.style.add("background-color", "red");     page.form.controls.add(b); } 

Popular posts from this blog