2
Reply

c# eventhandler

zafer ozer

zafer ozer

Apr 6 2012 7:59 AM
1.8k
hi, i need help on my lessons about eventhandler.

i will add imagebuttons into the cells of a table(asp:table):

ImageButton btnconfirm = new ImageButton();
btnconfirm.ImageUrl = "images/confirm.jpg";
btnconfirm.ID = bugun.AddDays(ekle).ToShortDateString();

and then i want to run the "btnconfirm_click" program, when user clicks a imagebutton.

btnconfirm.Click += new ImageClickEventHandler(this.btnconfirm_click);

i add the imagebuttons into the cells:
myCells.Controls.Add(btnconfirm);

then i add the cell to the row, and row to the table. when i run the program everything is allright, but when click the imagebuttons, they dont work.

where is the mistake, please help.

all the codes are these:


TableCell myCell= new TableCell();

ImageButton btnconfirm = new ImageButton();
btnconfirm.ImageUrl = "images/confirm.jpg";
btnconfirm.ID = bugun.AddDays(nmbr).ToShortDateString();
nmbr++;
btnconfirm.Click += new ImageClickEventHandler(this.btnconfirm_click);

myCells.Controls.Add(btnconfirm);

myCells.CssClass = "stil1";

myRows.Cells.Add(myCells);

Table1.Rows.Add(myRows);

Answers (2)