2017-11-11 8 views
-1

버튼을 누르면 해당 HTML 코드에서 value = "[email protected]"을 가져 와서 텍스트 상자에 넣고 싶습니다. 이거 할 생각이야?WebBrowser에서이 HTML 값을 가져 와서 텍스트 상자에 넣는 방법은 무엇입니까?

<input id="mail" onclick="select(this);" data-original-title="Your temporary Email address" class="mail opentip" value="[email protected]" data-placement="bottom" title="" type="text" readonly=""> 

이 코드를 사용하고 있지만 작동하지 않습니다.

WebBrowser1.Document.GetElementById("value").InvokeMember("click") 
TxtBox_Email.Text = Clipboard.GetText() 

답변

1

당신은 value attribute(HAH!)의 값을 얻기 위해 GetAttribute() method를 사용할 수 있습니다. 속성은 input 요소에 쓰여진 값을 보유합니다. 그런데

GetElementById()이 경우 "메일" 아닌 "값이"요소의 ID 기대.

Dim MailElement As HtmlElement = WebBrowser1.Document.GetElementById("mail") 

If MailElement IsNot Nothing Then 'Necessary check: Was the element found? 
    TxtBox_Email.Text = MailElement.GetAttribute("value") 
End If 
+0

@ SérgioWilker : 기꺼이 도와 드리겠습니다! 행운을 빕니다! –