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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Niradhip ChakrabortyPosted Jul 15, 2008, 7:17 PM
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
}