pressing download button in c#

Please see http://www.bmfbovespa.com.br/en_us/products/indices/broad-indices/brazil-broad-based-index-ibra-composition-index-portfolio.htm
At the bottom of the page there is a download button.
How do I press this download button from a C# program?
AlHal2Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zephyr_hex (Megan)DeveloperCommented:
You can't "press  a button" from server side code.  C# runs before the page is loaded to the client.  Interactions, like button pressing, occur on the client side.  If you want to press a button, you must use a client side language, like jQuery / JavaScript.
0
AlHal2Author Commented:
I've used a tiny bit of JavaScript in my own webpages.  This page is not my own.
How would I go about it.  Do you have any sample code?
0
zephyr_hex (Megan)DeveloperCommented:
This will click the link:

$("a[id$='Conteudo_Export_Test']").click();

Open in new window


You will want to wrap that inside a document ready function, so that it doesn't run until the DOM is loaded.

Here is a demo:  https://jsfiddle.net/zephyr_hex/rg90u61v/

HTML

<a href="" id="ctl00_contentPlaceHolderConteudo_Export_Test">Download</a>
<span></span>

Open in new window


jQuery

$(document).ready(function() {
   //test:  capture the click event
	$("a[id$='Conteudo_Export_Test']").on('click', function() {
  $('span').append('The link was clicked');
  });

  //click the Download link
	$("a[id$='Conteudo_Export_Test']").click();
});

Open in new window

0
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

AlHal2Author Commented:
Thanks.  How can I schedule this to run at a particular time of day?
0
AlHal2Author Commented:
I've put this into a sample webpage.  How do I determine where the downloaded file goes?

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
   
   
        $(document).ready(function () {
            //test:  capture the click event
            $("a[id$='Conteudo_Export_Test']").on('click', function () {
                $('span').append('The link was clicked');
            });

            //click the Download link
            $("a[id$='Conteudo_Export_Test']").click();
        });
    
    
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    
    

        
        <a href="" id="ctl00_contentPlaceHolderConteudo_Export_Test">Download</a>
    
</asp:Content>

Open in new window

0
zephyr_hex (Megan)DeveloperCommented:
The file download is usually presented with HTTP headers and a MIME type that matches the file extension.  That triggers the browser to download the file.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AlHal2Author Commented:
Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.