views:

158

answers:

1

I have a C# app that uses a web browser control to display some HTML and do some JScript in the background.

How do I integrate this with other system calls? Do I call other C# code from JScript/VBScript? Do I need to do it from the form itself?

+1  A: 

When I need javascript hosted in a webbrowser control to call back to the parent, I have it try to navigate the page to another URL. Then in the webbrowser's "BeforeNavigate" event, I get the URL the page was trying to go to, parse out any arguments, dispatch the request to the other C# code, then cancel the original navigate request.

David
may want to use a custom protocol portion with this technique.. I usually do the same though.
Tracker1
Yeah, I'll prefix the URLs with "app://". That makes it easy in the C# event handler to tell if we need to start processing it as an app event or just as a regular URL.
David