I'd like to know whether it's possible to pass data from a C# application (e.g. WPF) to a web-page (i.e. an HTML page with Javascript) in an embedded Web Browser. If so, how?
Thanks in advance for your help!
I'd like to know whether it's possible to pass data from a C# application (e.g. WPF) to a web-page (i.e. an HTML page with Javascript) in an embedded Web Browser. If so, how?
Thanks in advance for your help!
You can invoke methods (and thus pass data) in your C# code from JavaScript using Window.external. Try googling for this keyword, more information will come up quickly.
This blog post has a good, simple (WPF-)example how to invoke a C# method from JavaScript using Window.external. Another keyword here is [System.Runtime.InteropServices.ComVisibleAttribute(True)]. You have to mark your handler class with this attribute to be accessible from JavaScript. And finally you tell your WebBrowser control about the handler class via its ObjectForScripting property.