1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
   |     public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                Button bouton1 = new Button();
                bouton1.Click += new EventHandler(bouton1_Click);
                bouton1.Text = "bouton1";
                contenu.Controls.Add(bouton1);
 
        }
        protected void bouton1_Click(object sender, EventArgs e)
        {
            Button bouton1 = ((Button)sender);
            bouton1.Text += "1";
            Button bouton2 = new Button();
            bouton2.Click += new EventHandler(bouton2_Click);
            bouton2.Text = "bouton2";
            bouton1.Parent.Controls.Add(bouton2);
        }
 
        protected void bouton2_Click(object sender, EventArgs e)
        {
            Button bouton = ((Button)sender);
            bouton.Text += "2";
 
        }
    } | 
Partager