1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

vb.net question

Discussion in 'Visual Basic .NET' started by astradamasta, Jan 11, 2009.

  1. astradamasta

    astradamasta Registered Member

    Joined:
    Nov 24, 2008
    Messages:
    56
    Likes Received:
    8
    I am trying to auto fill a "text area" on a web page using the webbrowser control. I know how to fill in when the web page's source code uses <input name=

    i just use wb.Document.GetElementById("email").InnerText

    anyone know how to fill in a text area.

    thanks
     
  2. crashed

    crashed Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 13, 2008
    Messages:
    958
    Likes Received:
    1,198
    Occupation:
    Guru-slayer
    Location:
    Behind the VPN...
    Home Page:
    Depending on what your doing, why not just save the page to disk, and then search and replace the various controls with value="<content>" then reload the page, and then just use Javascript to Invoke?

    If you wanna do it that way though, its simply
    wb.Document.GetElementById("textarea").Value = "content"
     
  3. astradamasta

    astradamasta Registered Member

    Joined:
    Nov 24, 2008
    Messages:
    56
    Likes Received:
    8
    i tried that code you gave me and it says that value isnt a member of system.windows.forms.htmlelement
     
  4. crashed

    crashed Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 13, 2008
    Messages:
    958
    Likes Received:
    1,198
    Occupation:
    Guru-slayer
    Location:
    Behind the VPN...
    Home Page:
    I've sent you a pm with a link to a sample project that does exactly what you want.

    For reference for anyone else with the same questions or interested in browser automation please see:

    Code:
    http://www.vbforums.com/showthread.php?t=416275
    The sample illustrates:
    * Getting a value of an HTML input element
    * Setting a value of a HTML input element
    * Getting a value of an HTML text area
    * Setting a value of a HTML text area
    * Set HTML radio buttons selected or not
    * Click an HTML button
    * Submit an HTML Form
    * Get the sources for all images in HTML document
    * Get and display all the links in the HTML document
    * Alter non form elements (like changing the color of a DIV tag)
    * Getting values from an HTML Select element (value and selected index)
    * Display page HTML source
    * Run a javascript that is in the HTML Page
    * click a checkbox in an HTML form
    * Print the current page (with printer selection dialog)
    * Added 8/24/2006 - Highlight webpage text via code
     
    Last edited: Jan 11, 2009
  5. crashed

    crashed Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 13, 2008
    Messages:
    958
    Likes Received:
    1,198
    Occupation:
    Guru-slayer
    Location:
    Behind the VPN...
    Home Page:
    Future reference the solution to the problem was

    Code:
    Dim document As System.Windows.Forms.HtmlDocument = wb.Document
    Dim theform As System.Windows.Forms.HtmlElement = document.All("f")
    theform.All("body").InnerText = "Changes Test"
    With 3 steps:
    document captured the entire html document from the browser
    theform selected the form that we wanted to work with called "f"
    and then we selected the textarea called "body" and updated its contents
     
    • Thanks Thanks x 3
  6. astradamasta

    astradamasta Registered Member

    Joined:
    Nov 24, 2008
    Messages:
    56
    Likes Received:
    8
    awesome man that really gave me what i need. thanks for the help