Question nullreference exception in web browser

tcesurya

New member
Joined
Feb 10, 2013
Messages
2
Programming Experience
Beginner
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then
WebBrowser1.Navigate(Me.TextBox1.Text)
WebBrowser1.Document.GetElementById("Email").SetAttribute("value", "tcesurya")


End If



End Sub

i am getting nullreference exception why plz explain
 
Last edited:
Navigate is asynchronous, no document has been loaded when it returns. You have to handle DocumentCompleted event and check ReadyState property to be completely loaded before you access the Document property.
 
Navigate is asynchronous, no document has been loaded when it returns. You have to handle DocumentCompleted event and check ReadyState property to be completely loaded before you access the Document property.

how to check readystate property can u plz modify my code so that it works properly thanks in advance
 
Search forum for 'readystate', you'll quite a lot of examples for this.
 
Back
Top