Why click won't fire?

D

Dave E

Hello,

I am having a rather annoying problem. I have written a program that
downloads a web page, fills in some fields then clicks a button to submit the
form. On some systems this works just great, on others the click event never
fires. I can get the form, fill it out, but when click is fired, nothing
happens. I am using the .net 2.0 webbrowser control to get the page and
access its elements. Here is the code I use to actually submit the form:

elcol = doc.Forms;
object obj = elcol[1].DomElement;
System.Reflection.MethodInfo mi = obj.GetType().GetMethod("submit");
mi.Invoke(obj, new object[0]);

I am assuming that since it works on some machines and not others, there is
some setting in IE or somewhere that causes this not to work. Anyone have
any suggestions?

Thanks,
 
W

wmain

I use a slightly different approach. It has always worked for me.

Here is some example code that I use to parse a login form and click the submit button.

foreach (HtmlElement element in wb.Document.All)
{
if (element.Name == "username")
username = element;
if (element.Name == "store_id")
store_id = element;
if (element.Name == "password")
password = element;
if (element.Name == "processing")
processing = element;
}
if (username != null && store_id != null && password != null && processing!=null)
{
username.InnerText = "erttrtre";
store_id.InnerText = "wertwertwert";
password.InnerText = "wertertwt";
processing.InvokeMember("click");
}
 

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

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,165
Latest member
JavierBrak
Top