public partial class Carro : System.Web.UI.Page { private Button miBoton = new Button(); protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { miBoton.Click += new System.EventHandler(MiBoton_Click); } } public void AgregarBoton() { Button miBoton = new Button(); miBoton.ID = "BtnCheck"; miBoton.ForeColor = System.Drawing.Color.Silver; miBoton.Font.Size = 9; miBoton.BackColor = System.Drawing.Color.Indigo; miBoton.Text = "CHECKOUT"; miBoton.Click += new System.EventHandler(MiBoton_Click); miBoton.Width = 120; miBoton.Height = 30; PlaceHolder1.Controls.Add(miBoton); } public void MiBoton_Click(Object sender, System.EventArgs e) { Button bt = (Button)sender; Session["p"] = "fsdfsdfsf"; Label2.Text = Session["p"].ToString(); } }