Classic ASP - how to export data from modal window?

asp Canada
  • 14 years ago

    Hi there

    I have this modal dialog window that shows the first 5 rows of a record set.

    There is an Export ALL button so the user doesn't have to scroll through each page to see the result but can just export to a comma-delimited file.  The file is .txt (not .csv not .xsl) that just looks as simple as:

    LastName,FirstName,EmployeeId
    McDonald,Robert,E0001
    Wong,Denny,E0002

    I thought it is an easy thing, but it feels like it is COMPLETELY IMPOSSIBLE!!

    I have no idea how to do that.  I'm on a modal window so if I do a <form> and post the action to itself, then a new blank window comes up.  But if I don't do a post, I don't know how I can hit this button and then the server can run the data retrieval and send the result back to the client....

    All I want to do is that, as soon as the user hits this button, there will be a File SaveAs dialog box comes up that lets the user decide the name and the location, and then the txt file gets downloaded there.  NOTE:  since the grid shows only the first five rows, I have to call my data retreival process (stored proc in this case) to specify retrieving all rows, so some data exported is not currently in the grid.

    Can you suggest how I should go proceed?

    Thanks a lot
    CC

  • 14 years ago

    Could the page that displays the first 5 rows also create a text file of all rows in the format that you require, then maybe use some of this article http://www.developerfusion.co.uk/show/2235/ to stream the file just created as a binary stream when a link / button is pressed. As far as I am aware it won't matter that a new blank window would happen when the link / button is pressed as it should just present the user with the save dialogue instead of a webpage, if I understand both the article and your requirements correctly.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“XML is like violence - if it's not working for you, you're not using enough of it.”