Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
so basically i have folder the normal concept for this

if (webbrowser1.documenttext.contains ("about"))
{
webbrowser1.document.getelementbyid("aria-id-29371579884").InvokeMember("Click")
messagebox.show("YES")
}

but it stops at the getelementbyid bit saying

Object reference not set to an instance of an object


any help in this matter please also tried in vb and still the same error :(
Posted
Comments
Richard C Bishop 2-May-13 14:46pm    
This exception means you are using an object before instantiating it. Debug your application and find which line it is being thrown. This will help you solve the issue.

Check your names. The only reason you get a "Not set to an instance" error is when you have tried to use a property or method of a null value. In this case, to get to the line you must have a value in webrowser1 (or the if condition would have thrown the exception), so the chances are that the WebBrowser.Document exists as well. Which leaves us with getelementbyid returning a null. So check your name - is there a control called "aria-id-29371579884"?
 
Share this answer
 
Comments
[no name] 2-May-13 14:56pm    
Orignalgriff

the html for the page says



what do you think i should do it is a button where you click it and two options/buttons come down i am using the id from one of the drop down buttons

what shall i do?

please
OriginalGriff 2-May-13 15:07pm    
Check that the drop down has it's ID property set correctly in the HTML.

Something tells me it hasn't - since that is why GetElementById returns a null value :laugh:
http://msdn.microsoft.com/en-GB/library/system.windows.forms.htmldocument.getelementbyid(v=vs.80).aspx

If you still think it has, post the HTML which create the drop down.
If the search is failed, it returns undefined object. Then you try dereferencing it by calling InvokeMember, which throws the exception. Either handle exception or make sure the search result of document.getElementById is defined: http://www.w3schools.com/jsref/jsref_undefined.asp[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900