Hi I am dynamically creating link buttons in the list of "ul li". Then I try to associate each link button with a click event, where I set a label in the link button text. however, the event that should fire does not fire?
if (!Page.IsPostBack) { int listItemIds = 0; foreach (Node productcolour in product.Children) { HtmlGenericControl li = new HtmlGenericControl("li"); LinkButton lnk = new LinkButton(); lnk.ID = "lnk" + listItemIds; lnk.Text = productcolour.Name; lnk.Click += new EventHandler(Clicked);
the above is wrapped in if (! page.ispostback), and the label text is never set anywhere. heres to the event
protected void Clicked(object sender, EventArgs e) { LinkButton lno = sender as LinkButton; litSelectedColour.Text = lno.Text; }
source share