Well if i'm creating an event programmatically and run it outside the page_load
or page_init
then it's not working. Do you have to write the code inside the page_load
or page_init
?
the code below is just a little example that works inside the page load or init but not outside.
protected void btnAddProduct_Click(object sender, EventArgs e)
{
Button b = new Button();
b.Text = "Add product";
b.ID = "btn_Back";
b.Click += new EventHandler(Button_Click);
form1.Controls.Add(b);
}