Reputation: 30343
i created a dynamic control but i want to create events dynamically for the control for example button i created a dynamic button like.
Button btn = new Button();
btn.Text = "click";
form1.Controls.Add(btn);
Upvotes: 0
Views: 598
Reputation: 2389
but = new Button(); but.Click += new EventHandler(this.button_Click); form1.Controls.Add(but);
Upvotes: 0
Reputation: 5944
You can do it in the Init event of the page, by simply setting the btn.Clicked event to the appropriate delegate.
btn.Clicked += this.btnClickedEventHandler;
Upvotes: 2