locked
How can i getelemetbyid with Webview cLass?

    Question

  • Hello everyone! 

    I just want to use this simple line of code so i can get the value of an element with the webview class.

     label.Text = webBrowser.Document.GetElementById("idname").InnerText;

    But webview has no such property....Please help me!

    Thank you!

    Saturday, March 15, 2014 12:56 AM

Answers

  • As you note, there is no such property. The WebView doesn't provide direct access to its DOM. You will need to do any DOM examination or manipulation from within the WebView's content HTML.

    You can inject and run JavaScript to do this with InvokeScript. See Matt's blog entry How to inject javascript into a WebView page

    --Rob

    Saturday, March 15, 2014 1:11 AM
    Owner

All replies

  • As you note, there is no such property. The WebView doesn't provide direct access to its DOM. You will need to do any DOM examination or manipulation from within the WebView's content HTML.

    You can inject and run JavaScript to do this with InvokeScript. See Matt's blog entry How to inject javascript into a WebView page

    --Rob

    Saturday, March 15, 2014 1:11 AM
    Owner
  • Thank you Rob. It was very helpful!
    Saturday, March 15, 2014 3:03 AM