简体   繁体   中英

How to store data from webview in localdata UWP

For my app I want to store the usernames that are entered into the local appdata. I do not know how to store the value that is entered in the textbox from the webview to the localdata. Looking across the internet I also could not find any right answer.

I have read InvokeScriptAsync is a method that is used for this kind of things but there's not instruction on how to use it in my case.

I hope someone will have a solution for me.

Thanks in advance!

You can use InvokeScriptAsync to both inject javascript and retrieve html from WebView .

Here is the code to retrieve text entered by user in the WebView. Let consider username is the id of html input field and you want to retrieve what ever the text entered into that input by user.

string username = await MyWebView.InvokeScriptAsync("eval", new string[] { "document.getElementById('username').value;" });

This should called on NavigationCompleted callback method of WebView.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM