Reputation: 33
I am currently working on an app where i use a webview to display a webapp. I want to make it so that a user does not have to type his username everytime he starts the app . I want to automatically fill the textbox in the webview with text from c#. I have the following code untill now but I think my javascript is far from good (I don't have any specific knowledge about javascript).
private async void asyncjevoordeuser()
{
var inputValue = "test";
var functionString = string.Format(@"document.getElementById('username');", inputValue);
await WebView.InvokeScriptAsync("eval", new string[] { functionString });
}
I am calling this method from
private void WebView_LoadCompleted(object sender, NavigationEventArgs e)
{
asyncjevoordeuser();
}
I hope someone can help me out.
Upvotes: 0
Views: 585
Reputation: 428
await WebViewObj.InvokeScriptAsync("eval", new string[] { "document.getElementById('username').value = 'username here';" });
Upvotes: 3