Reputation: 121
I am working on windows phone 8.1 runtime universal app and using webview to go to page. I want to be able to download the HTML on the page into a string so I can use t in my app. I have used these links for help but to no avail:
http://codesnack.com/blog/2012/01/05/metro-webview-source-workarounds/
Retrieve Inner Text from WebView HTML in Windows/Windows Phone 8.1
so I added this line in my NavigationCompleted event handler
string pageContent = webBrowser1.InvokeScriptAsync("eval", new string[] { "document.documentElement.outerHTML;" }).ToString();
But when I step through the code all I get is System.__ComObject as the value for pageContent .
Any ideas what is going on here?
Thanks!
Upvotes: 0
Views: 822
Reputation: 21899
InvokeScriptAsync returns a IAsyncOperation not a string. If you call ToString() on it you'll just get the type of the object (System.__ComObject).
You'll almost always want to "await" Async functions like this. That will process the returned operation, wait for it to finish, and then return its type.
If you change your code to the following then pageContent will get the HTML from your evaled function:
string pageContent = await webBrowser1.InvokeScriptAsync("eval", new string[] { "document.documentElement.outerHTML;" });
Upvotes: 1