J
JezB
I'm adding WebControl objects to a Page dynamically on Page_Load, but I'm
having trouble attaching events to these. For example, adding an image
button :-
ImageButton nb = new ImageButton();
nb.ImageUrl = "text.gif";
nb.ToolTip = "Edit Text";
nb.Click += new ImageClickEventHandler(b1_Click);
myPlaceholder.Controls.Add(nb);
(myPlaceholder is a Placeholder object added to the Page at design time)
private void b1_Click(object sender, ImageClickEventArgs e)
{
// etc
}
Problem is, on clicking the button the event is not fired at all - it just
forces a postback - what am I doing wrong ?
having trouble attaching events to these. For example, adding an image
button :-
ImageButton nb = new ImageButton();
nb.ImageUrl = "text.gif";
nb.ToolTip = "Edit Text";
nb.Click += new ImageClickEventHandler(b1_Click);
myPlaceholder.Controls.Add(nb);
(myPlaceholder is a Placeholder object added to the Page at design time)
private void b1_Click(object sender, ImageClickEventArgs e)
{
// etc
}
Problem is, on clicking the button the event is not fired at all - it just
forces a postback - what am I doing wrong ?