ASP.NET form action file - writing to text file

Discussion in '.NET' started by icedragon, Jul 13, 2010.

  1. icedragon

    icedragon

    Joined:
    Jul 13, 2010
    Messages:
    1
    Hey guys,

    So I'm trying to write a javascript array to a server-side text file. I've got my form:

    Code:
    <form id="my_form" action="">  
    <input type="text" id="file_name" rows="1" cols="20">  
    <a href="javascript: submitform()">Save</a>  
    </form> 
    And the javascript code:

    Code:
    function submitform();  
    {  
    var d = seatsArray.join();  
    var url = "mysite/savetext.asp?seatsArray="+d + "&file_name=" +   
    document.getElementById("file_name").value;  
      
    document.getElementById("my_form").action = url;  
    document.getElementById("my_form").method = "POST";  
    document.getElementById("my_form").submit();  
    }
    And I'm not sure about how I can make an action file in ASP.NET for this form so that it will write the contents of this array (a separate line for each value) into a text file. It also needs to create the text file and name it what the user put in the "file_name" text box. I tried something briefly but it is incomplete:

    Code:
    <%  
    Dim objFSO, objTStream  
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")  
    Set objTStream = objFSO.CreateTextFile("THIS NEEDS TO BE WHAT THE USER ENTERED IN 'FILE_NAME'", True)  
    objTStream.WriteLine("THIS NEEDS TO BE THE ARRAY")  
    objTStream.Close  
    Set objTStream = nothing  
    Set objFSO = nothing  
    %>
    Can you help me out with how to make this work?

    Thanks!

    John
    icedragon, Jul 13, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Bloggs
    Replies:
    1
    Views:
    727
    Sudsy
    Aug 3, 2003
  2. rjweytens
    Replies:
    6
    Views:
    16,052
    rjweytens
    Jun 25, 2004
  3. John
    Replies:
    0
    Views:
    851
  4. iam247@gmail.com
    Replies:
    7
    Views:
    606
    iam247@gmail.com
    Aug 20, 2005
  5. iam247@gmail.com
    Replies:
    2
    Views:
    207
Loading...

Share This Page