prompt user to save asp page as .txt file

Posted on 2009-04-17
Last Modified: 2012-05-06
I have created a javascript function which would loop through the contents of a table and output the contents as essentially a text csv file which then displays on the browser in the same page.  In other words this function replaces the original display with the new text and displays that to the user.  I'm unsure how to structure the code so that it writes the data into a new tab or page in the browser rather than overwrites the original.  I also need to then prompt the user to download the created page and save as a .txt file.  I'm assuming this process would require asp code but since asp executes prior to javascript I'm not sure how to integrate the two.  Any help is greatly appreciated.
Question by:drmans
    LVL 9

    Expert Comment

    you may incorporate alert function at the end of ur javascript

    eg:  alert("Please save the new created page in a text file");


    Author Comment

    I thought about that option but ideally the script would AUTOMATICALLY force a download dialog box.  I've seen it done via asp headers but there would need to be a way to execute the asp code AFTER the javascript has finished executing which I don't think is possible?  

    Author Comment

    Let me rephrase the question to simplify a bit...

    How would you go about forcing a download dialog box on a dynamically created page?
    Ultimately I would like to use some asp code to simply 'copy' the text displayed and offer the user a 'save as' box so that the user doesn't need to right click and save as manually.
    LVL 9

    Accepted Solution


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
    This article will show, step by step, how to integrate R code into a R Sweave document
    Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
    Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now