|
-
Oct 4th, 2010, 09:27 AM
#1
Thread Starter
Frenzied Member
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
-
Oct 4th, 2010, 09:38 AM
#2
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
-
Oct 4th, 2010, 09:50 AM
#3
Thread Starter
Frenzied Member
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..
-
Oct 4th, 2010, 10:04 AM
#4
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
-
Oct 4th, 2010, 10:19 AM
#5
Re: Set Focus on WebBrowserControl Item
Please mark you thread resolved using the Thread Tools as shown
-
Oct 4th, 2010, 11:01 AM
#6
Thread Starter
Frenzied Member
Re: Set Focus on WebBrowserControl Item
thanks that last post helped me out.
-
Oct 4th, 2010, 11:02 AM
#7
Thread Starter
Frenzied Member
Re: Set Focus on WebBrowserControl Item
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|