AB Vyas AB Vyas - 2 months ago 13
ASP.NET (C#) Question

How can i create dynamic button click event on dynamic button?

I am creating one button on page dynamically.
Now I want to use button click event on that button.

How can I do this in c# asp.net?

Answer
Button button = new Button();
button.Click += (s,e) => { your code; };
//button.Click += new EventHandler(button_Click);
container.Controls.Add(button);

//protected void button_Click (object sender, EventArgs e) { }