Kevin

Kevin

  • NA
  • 3
  • 10.4k

Get Element Value from Web browser control

Oct 31 2011 4:38 PM
I'm calling a asp.net web page in a winform webbrowser control.

The webbrowser is being used to take the user information and submit it the database, creating an item
On the winform I have a submit button that invokes ("click")

        Dim doc As HtmlDocument
        doc = WebBrowser1.Document
        doc.GetElementById("btnsubmit").InvokeMember("Click")

Which works fine

After I need my winform to know what item was created.   On my webpage I have a hidden field.  After submit the hidden field is populated with the item value.

I now need the winform to read this value.
       
        Dim doc As HtmlDocument = WebBrowser1.Document
        Dim docelement As HtmlElement = doc.GetElementById("hdnitemid")
        item_id = docelement.GetAttribute("value")

Not working item_id returns nothing.

If I look at the webpage source, the hidden value is populated with an value.  I think posting the value on to another page will fix my issue, but I want to avoid doing that. 

Help will be appreciated.

Answers (1)