Reputation: 228
Can a Webbrowser control communicate with the C# class that created it? Is there anyway to set up something like ExternalInterface that works in Flash? I'm trying to get the following code to write to the console in C# or call a method in C#.
HtmlElement button = webBrowser1.Document.CreateElement("div");
button.InnerHtml = @"<INPUT TYPE='Text'><P><INPUT TYPE='Submit' Value='Submit' onclick='console.log('Clicked');'>";
webBrowser1.Document.GetElementById("myID").AppendChild(button);
Upvotes: 0
Views: 297
Reputation: 103525
A pretty hacky way would be to communicate via current location.. Button click:
onclick="window.location.href='#clicked';"
Then handle webBrowser1_Navigated
and check the Url
property. Split out the message after the #
and log it to the console or call the method.
Upvotes: 1