I am using the new WebView2 to insert text into a textbox within Edge. I have the event below:
webView.NavigationCompleted += new EventHandler<CoreWebView2NavigationCompletedEventArgs>(InputText);
It runs the following code:
private async void InputText(object sender, CoreWebView2NavigationCompletedEventArgs args)
{
await webView.ExecuteScriptAsync("document.getElementById('Textbox').value = 'Test';");
}
This works for the test site I am playing with. However, I want to pass the script as a string variable into the InputText method. Trying to add it to it states, that there is no overload for the delegate such as:
webView.NavigationCompleted += new EventHandler<CoreWebView2NavigationCompletedEventArgs>(e => InputText(this, e, "Test"));
private async void InputText(object sender, CoreWebView2NavigationCompletedEventArgs args, string test)
{
await webView.ExecuteScriptAsync("document.getElementById('Textbox').value = 'Test';");
}
Is there a way to overload this to add a parameter?