Results 1 to 11 of 11

Thread: Trying to enter a field on a website with code i've used on several projects...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2014
    Posts
    159

    Trying to enter a field on a website with code i've used on several projects...

    Hey Guys,

    I'm trying to enter information into this field on a site with code i've used before but its still not working:

    Code:
    <td width="100%" style="padding-left:7px;">
    <input id="arg01_UserName" type="text" 10";"="" style="width:120px;color:black;font-size: 10pt;height:22px;maxlength=" name="arg01_UserName"></input>

    Code:
       theElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
    
            For Each curElement As HtmlElement In theElementCollection
    
                Dim controlName As String = curElement.GetAttribute("id").ToString
    
                If controlName = "arg01_UserName" Then
    
                    curElement.SetAttribute("value", "Admin")
    
                End If
    
            Next

    Code:
      Dim username As HtmlElement = Me.WebBrowser1.Document.All.Item("arg01_UserName")
            username.InnerText = "Admin"

    Any ideas?

  2. #2
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,390

    Re: Trying to enter a field on a website with code i've used on several projects...

    The id is arg01_UserName, why get an element bytagname if the id is present.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2014
    Posts
    159

    Re: Trying to enter a field on a website with code i've used on several projects...

    Quote Originally Posted by ident View Post
    The id is arg01_UserName, why get an element bytagname if the id is present.


    still didnt work:

    Code:
     WebBrowser1.Document.GetElementById("arg01_Username").SetAttribute("value", "Admin")
    Also tried:

    Code:
     WebBrowser1.Document.Forms.Item(0).GetElementsByTagName("input").Item("arg01_UserName").SetAttribute("value", "Admin")
    Last edited by jdarville; Apr 21st, 2015 at 08:26 PM.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2014
    Posts
    159

    Re: Trying to enter a field on a website with code i've used on several projects...


  5. #5
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,390

    Re: Trying to enter a field on a website with code i've used on several projects...

    Code:
            Dim element = Me.WebBrowser1.Document.GetElementsByTagName("input").Cast(Of HtmlElement)().FirstOrDefault(Function(el) el.Name = "arg01_UserName")

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    May 2014
    Posts
    159

    Re: Trying to enter a field on a website with code i've used on several projects...

    Quote Originally Posted by ident View Post
    Code:
            Dim element = Me.WebBrowser1.Document.GetElementsByTagName("input").Cast(Of HtmlElement)().FirstOrDefault(Function(el) el.Name = "arg01_UserName")
    Ident, thank you very much for responding. I really appreciate your time.

    How do I pass the value with your code? I tried the following but it doesnt work:

    Code:
    Dim element = Me.WebBrowser1.Document.GetElementsByTagName("input").Cast(Of HtmlElement)().FirstOrDefault(Function(el) el.Name = "arg01_UserName")
    element.SetAttribute("value", "Admin")
    Code:
    Dim element = Me.WebBrowser1.Document.GetElementsByTagName("input").Cast(Of HtmlElement)().FirstOrDefault(Function(el) el.Name = "arg01_UserName")
    element.InnerText = "Admin"
    Code:
    Dim element = Me.WebBrowser1.Document.GetElementsByTagName("input").Cast(Of HtmlElement)().FirstOrDefault(Function(el) el.Name = "arg01_UserName" = "test")
    Last edited by jdarville; Apr 22nd, 2015 at 10:05 PM.

  7. #7
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,390

    Re: Trying to enter a field on a website with code i've used on several projects...

    element.SetAttribute("value", "Admin") works fine when compiling the example in a browser here. But you have not supplied the url so how can i test the code properly?

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    May 2014
    Posts
    159

    Re: Trying to enter a field on a website with code i've used on several projects...

    Quote Originally Posted by ident View Post
    element.SetAttribute("value", "Admin") works fine when compiling the example in a browser here. But you have not supplied the url so how can i test the code properly?

    Its an internal webpage on a printer but i downloaded the page and you can view it here:

    http://atlanticserviceinvoice.com/ex...72.21.2.35.htm

    Thank you very much!

  9. #9
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,390

    Re: Trying to enter a field on a website with code i've used on several projects...


  10. #10

    Thread Starter
    Addicted Member
    Join Date
    May 2014
    Posts
    159

    Re: Trying to enter a field on a website with code i've used on several projects...

    Quote Originally Posted by ident View Post


    Good find. I used that link but i'm still unable to enter the values. Can you give an example please?

  11. #11
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,390

    Re: Trying to enter a field on a website with code i've used on several projects...

    You have the element now. It's up to you to actually take the time to research. I had to research that it was an iframe. Make an effort and come back if you are stuck. I am not writing your project for you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width