how to create an asp button dynamically and add event to it
I'm trying to create a button dynamically on asp.net,but I can't add the event to it.What is wrong or missing below? Thanks in advance $ Button btn2 = new Button(); btn2.ID = "btnEdit"; btn2.Text = "Edit Member"; btn2.Click += new EventHandler(btnEdit_Click); form1.Controls.Add(btn2); I also tried like this: $ Button btn2 = new Button(); btn2.ID = "btnEdit"; btn2.Text = "Edit Member"; btn2.Attributes.Add("OnClick","btnEdit_Click); form1.Controls.Add(btn2);
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.