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.
http://img696.imageshack.us/img696/8158/errorapp.jpg
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
Re: Set Focus on WebBrowserControl Item
You need to read the control using .getElementById . Does that control has any id ?
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..
Re: Set Focus on WebBrowserControl Item
oh. What event you are handling this one ?
Re: Set Focus on WebBrowserControl Item
Re: Set Focus on WebBrowserControl Item
thanks that last post helped me out.
Re: Set Focus on WebBrowserControl Item