Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to invoke a C# method from Java script from WPF Web browser control?

I'm using a Tab control in WPF and the Tab control contains a WebBrowser control in first tab. I have some scripts and HTML content for the Webbrowser control and this works fine. Also I'm able to invoke the script method written inside the HTML content, but I need the vice versa as need to invoke a C# method from Javascript method.

Is it possible?

like image 846
Kamal Avatar asked May 06 '26 04:05

Kamal


1 Answers

You can specify an object which is accessible to be called directly from your JavaScript. Check out the property ObjectForScripting on the WebBrowser control for more information.

Also, here is another post which outlines it even better: Hosting and interacting with a webpage inside a WPF App

like image 65
Shawn Lehner Avatar answered May 08 '26 17:05

Shawn Lehner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!