title: How can I add a click event to my div from code behind?
body: <p>How can I add a click event to my div from code behind?</p>
  
  <p>Im looking upon clicking on the div to be greeted by a message box with would you like to delete this and a yes or no within the box?</p>
  
  <p>All from the code behind:</p>
  
  <pre><code>            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("&amp;nbsp&amp;nbsp&amp;nbsp;"+"{0}", reader.GetString(0))));
                  div.Style["clear"] = "both";
                  test1.Controls.Add(div);
  
              }
  </code></pre>
  
  <p>can you add a click event to it if so how?</p>