-
March 30th, 2011, 03:47 PM
#1
Newbie can't follow link in webbrowser to fillout a form
Hi,
I am new to C# and have a form with 2 buttons. One clicks on a link in a page which takes the webbrowser to a link that has a form. The second button fills out the form and clicks submit.
I would like to combine these buttons and noticed a http://support.microsoft.com/kb/180366 but am not sure if this is the way to make sure the 2nd page is loaded before continuing with my method. Any suggestions? I keep getting "Send InMail form not found".
Code:
if (webBrowser1.Document != null)
{
if (webBrowser1.Document.All["_contactDirectlyLink"] != null)
{
HtmlElement Send_InMailLink = webBrowser1.Document.All["_contactDirectlyLink"];
Send_InMailLink.InvokeMember("Click");
//mshtml.HTMLLinkElement Send_InMailLinkButton = (mshtml.HTMLLinkElement)Send_InMailLink.DomElement;
}
else
{
if (webBrowser1.Document.GetElementById("document-create_proposal") == null)
{
MessageBox.Show("Send InaMail link not found");
}
}
//is page loaded? if so, continue
if (webBrowser1.Document != null)
{
if (webBrowser1.Document.GetElementById("title-create_proposal") != null)
{
if (txtMsgTitle.Text != "")
{
webBrowser1.Document.GetElementById("title-create_proposal").SetAttribute("value", txtMsgTitle.Text);
}
else
{
MessageBox.Show("Please enter subject.");
return;
}
if (webBrowser1.Document.GetElementById("document-create_proposal") != null)
{
if (txtMessageBox.Text != "")
{
webBrowser1.Document.GetElementById("document-create_proposal").SetAttribute("value", txtMessageBox.Text);
if (webBrowser1.Document.GetElementById("proposalType-create_proposal") != null)
{
webBrowser1.Document.GetElementById("proposalType-create_proposal").SetAttribute("value", "JOB_OFFER");
}
if (webBrowser1.Document.GetElementById("rcptTelephone-contact-create_proposal") != null)
{
webBrowser1.Document.GetElementById("rcptTelephone-contact-create_proposal").SetAttribute("value", "(xxx) xxx-xxxx");
}
if (webBrowser1.Document.All["inmail-proposal-submit"] != null)
{
HtmlElement el1 = webBrowser1.Document.All["inmail-proposal-submit"];
mshtml.HTMLInputElement el2 = (mshtml.HTMLInputElement)el1.DomElement;
//el2.click();
webBrowser1.Document.GetElementById("proposalType-create_proposal").SetAttribute("value", "JOB_OFFER");
webBrowser1.Document.GetElementById("rcptTelephone-contact-create_proposal").SetAttribute("value", "(510) 525-3200");
el2.click(); //let's try with it now
}
}
else
{
MessageBox.Show("Please enter message.");
return;
}
}
else
{
MessageBox.Show("Send InMail form not found");
return;
}
}
else
{
MessageBox.Show("Send InMail form not found");
return;
}
}
Last edited by HanneSThEGreaT; March 31st, 2011 at 01:33 AM.
-
March 30th, 2011, 05:43 PM
#2
Re: Newbie can't follow link in webbrowser to fillout a form
It's not nice to scrape others data, as it's also against the AUP to discuss. Logging into another site is probably not allowed, either.
-
March 31st, 2011, 01:32 AM
#3
Re: Newbie can't follow link in webbrowser to fillout a form
Use CODE tags when posting code please.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|