title: Download File with WebBrowser Control On Click
body: <p>I need to download an excel file from a site.
  I created a WebBrowser control inside a Windows Form that navigates to the site, select a criteria, clicks a search button which opens up another page.</p>
  
  <p>Now on this page there is a link button with a javascript function, that downloads an excel file when it is clicked.</p>
  
  <p>the link code is the following:</p>
  
  <pre><code>&lt;a onclick="$find('ReportViewer').exportReport('Excel');" href="javascript:void(0)" style="color: rgb(51, 102, 204); font-family: Verdana; font-size: 8pt; padding: 3px 8px 3px 32px; display: block; white-space: nowrap; text-decoration: none;"&gt;Excel&lt;/a&gt;
  </code></pre>
  
  <p>I wrote a code in the WebBrowser to find the link with Text "Excel" and click it, but this opens up Internet explorer and prompts the user for download. 
  This is an automated process, so I don't need the prompt, I need the download to happen automatically and save the file in a specific directory.</p>
  
  <p>I tried to use this solution</p>
  
  <p><a href="https://stackoverflow.com/questions/15419632/download-a-file-through-the-webbrowser-control">Download a file through the WebBrowser control</a></p>
  
  <p>But it doesn't work in my case, I think because I don't have a direct url that ends with pdf or xls. It's a javascript call.</p>
  
  <p>Any ideas ?</p>