In my WebView2 i load my local html with js file, all works fine, but how can i run a script from my WinForm in WebView?
Till now i was using webBrowser in VB and i was doing it like this:
WebBrowser1.Document.InvokeScript("addProducts", New String() {"{ ""desc"": ""test"", ""qta"": 1, ""prezzo"": 2}"})
And now i was trying something like:
private async void prodotto_Click(object sender, EventArgs e)
{
await webView21.ExecuteScriptAsync("addProducts(\"{ \"desc\": \"test\", \"qta\": 1, \"prezzo\": 2})\"");
}
I've tryed it even like :
private void prodotto_Click(object sender, EventArgs e)
{
AddProduct();
}
async void AddProduct()
{
await webView21.CoreWebView2.ExecuteScriptAsync("addProducts(\"{ \"desc\": \"test\", \"qta\": 1, \"prezzo\": 2})\"");
}
But the script is not even reached...