I’m using HtmlElement to get an HTML element by it’s ID and trying to display this value and return it (as a String). The problem is that it sees it as an Object.
I have a webBrowser in the code with an HTML file that has:
<label id="Address" text="asdf"></label>
In my C++ header file I have
HtmlElement^ element = this->webBrowser1->Document->GetElementById("Address");
String^ asdf = element->GetAttribute("text");
return asdf;
This builds, but when I launch the program, I get an exception “Object reference not set to an instance of an object.”
I can’t use System::Convert.ToString(); either, it won’t let me build with that.
Any suggestions are appreciated. Thanks.
OK I finally figured out the problem after switching projects and coming back to it after a while.
I forgot the ‘System::Object^ sender’ part in my header file. Now all the HtmlElement stuff works.:
public: System::String^ GetAddress(System::Object^ sender)
Thanks for all your help.