webbrowsercontrol & reflection

P

phoenix

Hello,

I'm using the webbrowser control to display a webpage on my form. The first
problem is the gets fired for every image which is completed as well.
http://support.microsoft.com/?id=180366 describes a solution but I'm not
able to port the if to C# :

VB
---
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object,
URL As Variant)
If (pDisp Is WebBrowser1.Object) Then
Debug.Print "Web document is finished downloading"
End If
End Sub

C#
---
private void IE_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
if (????????????????????????)
MessageBox.Show("finished loading");
}


Then I want to use reflection to fill in a field on the form.

object [] _name = {"q"}; // the textbox to fill
object [] _value = {"value", "hello world"}; // the text to fill it with
object o = IE.Document.GetType().InvokeMember("getElemenById",
System.Reflection.BindingFlags.InvokeMethod, null, IE.Document, _name);
o.GetType().InvokeMember("setAttribute",
System.Reflection.BindingFlags.InvokeMethod, null, o, _value);

The above code compiles but when run it just hangs on "object o = ..." and I
don't see any reason why. Any ideas ?

TIA

Yves
 
N

Nicholas Paldino [.NET/C# MVP]

Yves,

I believe that the syntax for the event handler that you want is:

if (e.pDisp == IE.Object)
{

}

As for using reflection, why are you not binding to the MSHTML interop
library? It would make using all of this much, much easier.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top