I have a dynamically created table and in some of the cells i have an image button associated with the redBall_Click() handler
(here is the code behind)
TableCell cellOK = new TableCell(); cellOK.Style.Add(HtmlTextWriterStyle.TextAlign, 'Center'); cellOK.Width = new Unit('3%'); ImageButton redBall = new ImageButton(); redBall.CausesValidation = false; redBall.ID = id; redBall.ImageUrl = '~/App_Themes/DotRed.png'; redBall.Click += new ImageClickEventHandler(redBall_Click); cellOK.Controls.Add(redBall);
My problem is that the redBall_Click() method is never called (neither after the PostBack)
How can i solve this?
P.S. : I can’t use a static link because every ImageButton is associated with a specific ID that i must pass to the page i call (for example as a Session object)
I finally resolved (just yesterday).
I guess I was building my buttons too late: in the Page_PreRender (after the event was to be fired) maybe if i put the creation in Page_Load (yes, I create everything also on PostBack) it would handle the click, but I think I won’t try since I found a workaround.
I’ll explain for anyone who could have the same problem:
and in Page_Init()