How to add click event to my div from code?
I am looking at clicking on a div that will be welcomed in the message box, do you want to delete it and βyesβ or βnoβ in the field?
All of the code behind:
while (reader.Read()) { System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl("div"); div.Attributes["class"] = "test"; //div.Style["float"] = "left"; div.ID = "test"; Image img = new Image(); img.ImageUrl = String.Format("{0}", reader.GetString(1)); // this line needs to be represented in sql syntax //img.ImageUrl = "~/userdata/2/uploadedimage/batman-for-facebook.jpg"; img.AlternateText = "Test image"; div.Controls.Add(img); div.Controls.Add(ParseControl(String.Format("   "+"{0}", reader.GetString(0)))); div.Style["clear"] = "both"; test1.Controls.Add(div); }
can you add a click event to it, if so?
source share