B
Bill Compton
I have spent the last 5 hours trying to make this work, so I am a bit
frustrated with my ignorance.
I simply want to do the following:
On a WinForm, open a browser object to a particular url.
When I click a button on the WinForm, I want to be able to:
MessageBox.Show(axWebBrowser1.Document.body.innerHTML);
In other words, I want to be able to access the different parts of the DOM.
Ideally, if there were a variable set in the HTML document from code like:
<script>
document.myVar = "I am here"
</script>
Then I would be able to access it from the CSharp form.
Secondly, I want to be able to trigger an event in C# from the browser. The
idea is simple: I want the Javascript in the HTML document to fire a
"HeyPleasePayAttentionToMe" method residing somewhere in my c#.
Pseudo Code:
----test.htm
<html><script>document.myVar="I am here"</script><body>not much of a
body</body></html>
----containWebBrow.cs
using stuffneeded;
namespace stuffIdontUnderstand{
private PleaseDontAssumeIunderstandSyntax
putAButtonOnAForm = new Concept
makeButtonHaveClickEvent
void isMyBrainNow() hooked to the buttonClickEvent
function BrowserJustCalledMe()
end.
-----------------
I also need to be able to compile this on a machine that doesn't have Visual
Studio.
this is the compiler command I have been using this morning.
csc /r:axshdocvw.dll,shdocvw.dll,microsoft.mshtml.dll browTest.cs
I am able to show a browser window inside a form, but I am unable to
interact with it.
Any help would be greatly appreciated.
Thanks,
Bill
frustrated with my ignorance.
I simply want to do the following:
On a WinForm, open a browser object to a particular url.
When I click a button on the WinForm, I want to be able to:
MessageBox.Show(axWebBrowser1.Document.body.innerHTML);
In other words, I want to be able to access the different parts of the DOM.
Ideally, if there were a variable set in the HTML document from code like:
<script>
document.myVar = "I am here"
</script>
Then I would be able to access it from the CSharp form.
Secondly, I want to be able to trigger an event in C# from the browser. The
idea is simple: I want the Javascript in the HTML document to fire a
"HeyPleasePayAttentionToMe" method residing somewhere in my c#.
Pseudo Code:
----test.htm
<html><script>document.myVar="I am here"</script><body>not much of a
body</body></html>
----containWebBrow.cs
using stuffneeded;
namespace stuffIdontUnderstand{
private PleaseDontAssumeIunderstandSyntax
putAButtonOnAForm = new Concept
makeButtonHaveClickEvent
void isMyBrainNow() hooked to the buttonClickEvent
function BrowserJustCalledMe()
end.
-----------------
I also need to be able to compile this on a machine that doesn't have Visual
Studio.
this is the compiler command I have been using this morning.
csc /r:axshdocvw.dll,shdocvw.dll,microsoft.mshtml.dll browTest.cs
I am able to show a browser window inside a form, but I am unable to
interact with it.
Any help would be greatly appreciated.
Thanks,
Bill