title: How to create img tags dynamically from the code behind
body: <p>I have the following img tag:</p>
  
  <pre><code>  &lt;img  id="cross" runat="server"  /&gt;
  </code></pre>
  
  <p>I would like to create several img tags according to data the I'm getting back from the Database. but I'm keep getting an error 'System.Web.UI.HtmlControls.HtmlImage' does not allow child controls. </p>
  
  <p>How can I create img tag dynamically?</p>
  
  <p>For example if I'm getting back from the database 5 dots(XCoord,YCoord) to be created I want to create new 5 images.</p>
  
  <p>Here is my code:</p>
  
  <pre><code> Dim ds As DataSet = dba.GetIncidentsByZone(135, "02/11/2015", "05/12/2015", m_User.CompanyCode)
              If Not ds Is Nothing Then
                  For Each dr As DataRow In ds.Tables(0).Rows()
                      cross.Controls.Add(New HtmlImage() With {.Src = "C:/Inetpub/temp/pointer.gif", .Alt = ""})
                      cross.Style.Add("left", dr("XCoord").ToString() + "px")
                      cross.Style.Add("top", dr("YCoord").ToString() + "px")
                      cross.Attributes.Add("style", "visibility:visible")
                  Next
              End If
  </code></pre>