Hi: I have created Button control dynamically like
Button btn=new Button ().Now i wish to add a some Events to this Button control .Is it possible ...if so plz send me the code.
Thanks in advance
Hi: I have created Button control dynamically like
Button btn=new Button ().Now i wish to add a some Events to this Button control .Is it possible ...if so plz send me the code.
Thanks in advance
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Jul 15, 2008, 3:17 PM EDT
Button btn1 = new Button();
btn1.ID = "Test";
btn1.Click += new EventHandler(MyButtonClick);
LocateForm(this,btn1); -- FUNCTION TO ADD THE BUTTON
private void LocateForm(Control ctrl, Button btn){
foreach(Control mCtrl in ctrl.Controls){
if (mCtrl.GetType() == typeof(HtmlForm)){
mCtrl.Controls.Add(btn);
}else{
LocateForm(mCtrl,btn);
}
}
}
private void MyButtonClick(object sender, System.EventArgs e){
// DO SOMETHING
}