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.
Loading
KevinPosted Nov 1, 2011, 11:57 AM
Private WithEvents doc As HtmlDocument
Dim item_id As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
doc.GetElementById("btnsubmit").InvokeMember("Click")
End Sub
Private Sub WebBrowser1_Navigated(sender As Object, e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
doc = WebBrowser1.Document
End Sub
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
item_id = doc.GetElementById("hdnitemid").GetAttribute("value")
End Sub