I've got code in eBase to create a CSV from the displayed table data.
Now I want to download it to the User.
Ideally, I'd like code that will pop up the User's Save As dialog (as if they'd clicked on a link).
But, if eBase can't do that, I'd like to create an invisible hyperlink with the URL to the CSV as the link and have eBase simulate clicking on that link.
Can either of the above be done?
Download a file
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 12
- Joined: Sat Apr 04, 2015 3:43 pm
- Contact:
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
The invisible hyperlink approach will work:
Set up a hyperlink control linked to the csv file - you can set the url as a variable if you want to so it's dynamic. Then set this hyperlink control as hidden by adding advanced style of display:none; This puts it on the page but makes it invisible to the user. Give the hyperlink an id using HTML element properties (say csv1).
Then invoke some client side Javascript to click the invisible link to download the file at the appropriate time e.g.
You could include this Javascript in a variety of ways depending on what the trigger is to download the csv file:
o add it to an HTML control (initially hidden) and then just show this control at the appropriate time (you control this from the server)
o add it to a client-side ready event for a control (also controlled by the server)
o add it to some other client event (controlled by the client)
The browser's open/save dialog should appear.
There are probably smarter/tidier ways of doing this, but I tried it using an HTML control and it worked OK.
Set up a hyperlink control linked to the csv file - you can set the url as a variable if you want to so it's dynamic. Then set this hyperlink control as hidden by adding advanced style of display:none; This puts it on the page but makes it invisible to the user. Give the hyperlink an id using HTML element properties (say csv1).
Then invoke some client side Javascript to click the invisible link to download the file at the appropriate time e.g.
Code: Select all
<script>
var link = document.getElementById("csv1");
link.click();
</script>
o add it to an HTML control (initially hidden) and then just show this control at the appropriate time (you control this from the server)
o add it to a client-side ready event for a control (also controlled by the server)
o add it to some other client event (controlled by the client)
The browser's open/save dialog should appear.
There are probably smarter/tidier ways of doing this, but I tried it using an HTML control and it worked OK.
0 x
-
- Ebase User
- Posts: 12
- Joined: Sat Apr 04, 2015 3:43 pm
- Contact:
Who is online
Users browsing this forum: No registered users and 24 guests