Newbie can't follow link in webbrowser to fillout a form
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Newbie can't follow link in webbrowser to fillout a form

  1. #1
    Join Date
    Mar 2011
    Posts
    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 02:33 AM.

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    15,002

    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.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,099

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center