R
rh.krish
Hi,
I'm have a web form where I generate templates dynamically based on
the user input. When the user clicks the 'create' button I create a row
dynamically and create an ImageButton dynamically in that row. I also
tie the onClick event to a server side event handler, but when I click
the dynamically created ImageButton, the postback occurs, but the event
handler is not called. Here is what my code looks....
private HtmlTableCell CreateTableCell ( HtmlTableRow row, int
controlID, .......)
{
HtmlTableCell cell = new HtmlTableCell ( "td" );
ImageButton btnPlus = new ImageButton ();
btnPlus.ImageUrl = "images/plus.jpg";
btnPlus.ID = controlID; // id dynamically generated by the caller
and passed to this method
btnPlus.Click += new System.Web.UI.ImageClickEventHandler (
this.btnPlus_Click );
cell.Controls.Add ( btnPlus );
}
private void btnPlus_Click ( object sender, ImageClickEventArgs e )
{
// call some method....
}
Help is appreciated.
Regards,
Hari.
I'm have a web form where I generate templates dynamically based on
the user input. When the user clicks the 'create' button I create a row
dynamically and create an ImageButton dynamically in that row. I also
tie the onClick event to a server side event handler, but when I click
the dynamically created ImageButton, the postback occurs, but the event
handler is not called. Here is what my code looks....
private HtmlTableCell CreateTableCell ( HtmlTableRow row, int
controlID, .......)
{
HtmlTableCell cell = new HtmlTableCell ( "td" );
ImageButton btnPlus = new ImageButton ();
btnPlus.ImageUrl = "images/plus.jpg";
btnPlus.ID = controlID; // id dynamically generated by the caller
and passed to this method
btnPlus.Click += new System.Web.UI.ImageClickEventHandler (
this.btnPlus_Click );
cell.Controls.Add ( btnPlus );
}
private void btnPlus_Click ( object sender, ImageClickEventArgs e )
{
// call some method....
}
Help is appreciated.
Regards,
Hari.