Need help.... Went from WinForms to WPF. RE: WebBrowser - Click submit-VBForums
Results 1 to 4 of 4

Thread: Need help.... Went from WinForms to WPF. RE: WebBrowser - Click submit

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2008
    Posts
    35

    Unhappy Need help.... Went from WinForms to WPF. RE: WebBrowser - Click submit

    So I've went from a winform with my app to a new WPF version because I've wanted to to a ribbon.

    So I never used WPF before and pretty much took a crash course in the over the last couple of weeks. Everything has went smootly up until the last 48hrs.

    All I need to do it click "submit" on a form/ webpage inside of the WPF webbrowser. (TALK ABOUT A NITEMARE!)

    Old way that worked perfectly:

    wbGetHost.Document.All("get_host_info").Focus() ' Focus on textbox in form
    wbGetHost.Document.All("get_host_info").InnerText = rgServers.SelectedItem 'Set text of textbox
    wbGetHost.Document.GetElementById("Submit").InvokeMember("Click") ' Click submit button



    Everything works except the "click" event and I cant find anything on how to get it to work.



    Thanks for any help!

    Adam

  2. #2

    Thread Starter
    Member
    Join Date
    Oct 2008
    Posts
    35

    Re: Need help.... Went from WinForms to WPF. RE: WebBrowser - Click submit

    Wow... no one knows how to click a button in WPF??

    Well I guess I dont see so dumb after all...

  3. #3
    Member
    Join Date
    Jul 2012
    Posts
    52

    Re: Need help.... Went from WinForms to WPF. RE: WebBrowser - Click submit

    some people don't
    Last edited by ahmedkhairy; Nov 29th, 2012 at 06:04 AM.

  4. #4
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    www.vbforums.com
    Posts
    1,133

    Re: Need help.... Went from WinForms to WPF. RE: WebBrowser - Click submit

    Hi,

    In my WPF webbrowser loadcompleted event, I loaded google.com's page
    and then performing a search on that page by posting a value in it's
    search textbox, and then clicking it's search button.

    This uses mshtml namespace.

    Code:
    HTMLDocument document = (HTMLDocument)wbGetHost.Document;
                HTMLInputElement searchText = (HTMLInputElement)document.getElementById("q");
                searchText.value = "Bill Gates";
    
                HTMLInputElement searchButton = (HTMLInputElement)document.all.item("btnK", 0);
                searchButton.click();
    You can include some trappings/snippets to meet your needs...

    Greg
    Last edited by KGComputers; Dec 16th, 2012 at 11:44 PM.
    Thread Helpers 101
    I. Don't forget to
    rate my post if it has helped you.
    II. Mark your threads Resolved
    if it has been answered.
    III. Wrap your code snippets with code tags to make it readable.
    ____________________________________________________________________
    CodeBank Entries

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.