Results 1 to 7 of 7

Thread: Set Focus on WebBrowserControl Item

  1. #1

    Thread Starter
    Frenzied Member joefox's Avatar
    Join Date
    Oct 2004
    Posts
    1,318

    Set Focus on WebBrowserControl Item

    I have the below code that looks for a textbox on the webbrowsercontrols current webpage, and sets focus on it.

    When i run my app, it throws the errro below. if i press "yes" everything works fine, if i put "supress errors" option in the webbrowsercontrol, no errors but dosent work.



    Here is code.
    Code:
            Dim htmlEl As HtmlElementCollection = WebBrowser1.Document.All
    
            Dim iEnum As System.Collections.IEnumerator = htmlEl.GetEnumerator()
    
            While iEnum.MoveNext()
                Dim temp As HtmlElement = DirectCast(iEnum.Current, HtmlElement)
    
                If temp.Name.Trim().ToLower().Equals("status") Then
                    temp.InnerText = TextBox1.Text
                    temp.InvokeMember("focus")
    
                    Dim htmlEls As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
                    For Each htmle As HtmlElement In htmlEls
                        If htmle.GetAttribute("value").Contains("Share") Then
                            SendKeys.Send("{TAB}")
                            SendKeys.Send("{ENTER}")
                        End If
                    Next
    
                End If
            End While

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Set Focus on WebBrowserControl Item

    You need to read the control using .getElementById . Does that control has any id ?
    Please mark you thread resolved using the Thread Tools as shown

  3. #3

    Thread Starter
    Frenzied Member joefox's Avatar
    Join Date
    Oct 2004
    Posts
    1,318

    Re: Set Focus on WebBrowserControl Item

    It does, but the id changes everytime i go to the page.

    id=\"c4ca9e92b52d1c1fc0d282_input\"

    Also, what happens is, I have to click on it, for it to popup the real textbox..

  4. #4
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Set Focus on WebBrowserControl Item

    oh. What event you are handling this one ?
    Please mark you thread resolved using the Thread Tools as shown

  5. #5
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Set Focus on WebBrowserControl Item

    See this thread...
    Please mark you thread resolved using the Thread Tools as shown

  6. #6

    Thread Starter
    Frenzied Member joefox's Avatar
    Join Date
    Oct 2004
    Posts
    1,318

    Re: Set Focus on WebBrowserControl Item

    thanks that last post helped me out.

  7. #7

    Thread Starter
    Frenzied Member joefox's Avatar
    Join Date
    Oct 2004
    Posts
    1,318

    Resolved Re: Set Focus on WebBrowserControl Item

    solved

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