CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2009
    Posts
    4

    .NET WebBrowser Control and JavaScript

    Hello everyone,

    I am working on a project where I have to automate the process of entering data through a website. I decided to use the WebBrowser control in .NET for this task.

    The problem I am having is that when I try to click on certain buttons, nothing happens. After lookign at the HTML code, I saw a pattern. I can click on buttons where the input type is submit, but I have trouble with the buttons where input type is button and they only have an onclick attribute with javascript code.

    I have also tried to use the InvokeScript() method, but that also does not work.

    The only think I can think of is that JavaScript is disabled for the WebBrowser control.

    Can anyone give me any ideas on how I might be able to resolve this issue?

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: .NET WebBrowser Control and JavaScript

    WebBrowser control is the wrong approach. Trust me, I know. Did something similar to autoamtically fill a range of textboxes on a webpage. Have a look into the SHDocVw and the mshtml namespaces / libraries. Add a reference to them. ShDocVw you can find at :
    C:\Windows\System32
    And the mshtml you can find at :
    C:\Program Files\Microsoft.NET\Primary InterOp Assemblies

    Also include your using statements to reference these libraries.

    Once done, you can manipulate the webpage ( HTMLDocument ) object through code.

  3. #3
    Join Date
    Dec 2009
    Posts
    4

    Re: .NET WebBrowser Control and JavaScript

    I have heard of MSHTML, but what is SHDocVw?

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: .NET WebBrowser Control and JavaScript

    Here is a nice article giving you more details :

    http://www.codeproject.com/KB/toolba...oftMshtml.aspx

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured