I have a Windows Form with the Microsoft WebBrowser component. If I load an HTML file containing JScript, can my JScript code call a C# function on the form? Also, can C# call a JScript function in my HTML file?
There's an easy answer: NO WAY! But the truth is that there IS a way to get inside the MSHTML component (the one behind the Web browser). However, let me tell you it's FAR from trivial, requires significant COM interop code, implementing HIGHLY poorly or directly undocumented interfaces, etc. You're really asking for trouble.
The best advice I can give you is to take a look at Nikhil Kotari's page and perform a search for "MSHTML C# wrapper" in Google. You will find wrappers that will let you get HTML events handled in managed code (C#) and from there you can modify the DOM, etc.
Dig Deeper on C# programming language
Related Q&A from Daniel Cazzulino
Here Daniel Cazzulino explains how to load a DSL (domain specific language) domain model instance file programmatically. This requires the .NET type ... Continue Reading
Here we offer a glimpse at 12 of .NET development expert Danny Cazzulino's top ASP.NET questions and answers. Continue Reading
C# developers should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.