繁体   English   中英

将C#中的文本插入Webview-UWP

[英]Insert text from C# into webview - UWP

我目前正在使用WebView来显示WebApp的应用程序上工作。 我要这样做,以便用户不必每次启动应用程序时都键入用户名。 我想用来自C#的文本自动填充Web视图中的文本框。 直到现在我都拥有以下代码,但是我认为我的javascript远远不够(我没有关于javascript的任何特定知识)。

 private async void asyncjevoordeuser()
    {
        var inputValue = "test";

        var functionString = string.Format(@"document.getElementById('username');", inputValue);
        await WebView.InvokeScriptAsync("eval", new string[] { functionString });

    }

我从

     private void WebView_LoadCompleted(object sender, NavigationEventArgs e)
  {
      asyncjevoordeuser();
    }

我希望有人能帮助我。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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