Why do I get this Exception?
Object reference not set to an instance of an object.
With:
wb.Document.GetElementById("formfieldv1").InnerText = "some value"
Where wb is the name of the WebBrowser control.
Here is all the code:
Private Sub btnSend_Click(sender As System.Object, e As System.EventArgs) Handles btnSend.Click
Dim strFrom As String = txtFrom.Text
Dim strTo As String = txtTo.Text
Dim strMsg As String = txtMsg.Text
wb.Document.GetElementById("formfieldv1").InnerText = strFrom ' strFrom fills fine
End Sub
Update
As suggested in comments I modified code like this:
Dim doc = wb.Document
If (doc Is Nothing) Then
MsgBox("doc is nothing")
End If
Dim el = wb.Document.GetElementById("formfieldv1")
If (el Is Nothing) Then
MsgBox("el is nothing")
Else
el.InnerText = strFrom
End If
With that I am getting el is nothing. How do I solve this now ?
Alternatively if you guys can help me out with this that will solve my problem too:
wbisNothing, theDocumentisNothing, or aformfieldv1element does not exist in the document.Documentor the result ofGetElementById()is null.wbis dropped on form and I can see its members when typing it. Alsoformfieldv1is there as can be seen here freesmscraze.com forFromfieldwb.Documentto a variable. Then callGetElementByIdon that, assigning the result to an element, then setInnerTexton this variable. One of these will beNothing.elhere turnsNothing:Dim el = wb.Document.GetElementById("formfieldv1")How do I solve this plz ?