img element

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deviranir
    New Member
    • Dec 2008
    • 6

    img element

    Hi,

    In my application developing using VB .Net, i want a create HTML elements dynamically. I want to create as given below ,

    Code:
    <div class="contact">
    <dl class="user">
    <dt>
    <img class="onicon" title="Online" alt="Online" src="var/images/spacer.gif"/>
    </dt>
    <dt class="photo">
    <img class="usimg" title="Photo" alt="Photo" src="var/images/user.gif"/>
    </dt>
    <dd>aaa</dd>
    <dd class="statusmsg">Available</dd>
    </dl>
    </div>
    For the above, i have written code like this,

    Code:
        Public WithEvents htDoc As HtmlDocument
        Public WithEvents div As HtmlElement
        Public WithEvents dd1 As HtmlElement
        Public WithEvents dd2 As HtmlElement
    
                htDoc = WebBrowser1.Document
                div = htmlDoc.CreateElement("DIV")
                dd1 = htmlDoc.CreateElement("DD")
                dd2 = htmlDoc.CreateElement("DD")
               dd2.InnerHtml = "----------------------------------"
                dd1.InnerHtml = "TTTTTTTTT"
                div.AppendChild(dd1)
                div.AppendChild(dd2)
    
                htDoc.Body.AppendChild(div)
    The above code works fine. Now how do i append a img element. Also how do i mention the class ?
    Any help will be highly appreciated.

    Thanks,
    Dev.
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    To add an IMG tag, just do the same thing with IMG instead of DIV or whatever.

    To set attributes such as CLASS, use SetAttribute.

    Comment

    • deviranir
      New Member
      • Dec 2008
      • 6

      #3
      Hi,

      Thanks a lot !
      That worked .

      Dev.

      Comment

      Working...