Hi all,

My first venture into the use of webBrowser control.

I am writing an application that will enter some values in a (local) web site. 
It is really pretty simple in concept. The data will be scanned from a card and 
I need the web site then to process the data. I have most of this working. I 
set up a webBrowser control which logs onto the web site and then navigates to 
the correct web page and awaits the data entry.

My issue is that I get a runtime error when I am logging on to the site. Below 
is the code to logon - the error is thrown when on the "mi.Invoke(obj, new 
object[0]);" line.
I tried wrapping this in a try/catch block but this does not catch anything.

        HtmlElement username = this.webBrowser1.Document.All["txtUserid"];
                        username.SetAttribute("value", "usr");
                        HtmlElement pass = 
this.webBrowser1.Document.All["txtPassword"];
                        pass.SetAttribute("value", "usrpwd");

                        HtmlElement el = webBrowser1.Document.All["btnSubmit"];
                        object obj = el.DomElement;
                        System.Reflection.MethodInfo mi = 
obj.GetType().GetMethod("click");
                        mi.Invoke(obj, new object[0]); //   <--------- error 
thrown here.


The error is: " A runtime error has occurred. Do you wish to debug?   Line 157. 
  Error: Object expected."  (Yes &  No buttons)  If I click No, everything 
proceeds as normal
Line 157 is nowhere near this and I cannot see how it is at all related.

If I click Yes to debug and use the Microsoft Script Editor, I seem to be taken 
to the web page code which shows this:

<INPUT type="image" NAME="btnSubmit" src="/xyz/images/Submit1.gif"
                                                width="98" height="24" 
border="0" alt="SUBMIT" onClick="return fclick();" />

with the "   return fclick();   "   highlighted.


Can anyone suggest what I can try to sort this out?

Cheers,

Michael King

Reply via email to