need help!! noob here..

subhas

Newcomer
Joined
Feb 13, 2006
Messages
1
i have a aspx form. I fill in my particulars into the fields in this form and click submit. Then it automatically saves a copy of this form with all the inputs intact in a text file. The form also has a table. What are the codes to save a copy of this aspx file as a text file?
 
subhas said:
i have a aspx form. I fill in my particulars into the fields in this form and click submit. Then it automatically saves a copy of this form with all the inputs intact in a text file. The form also has a table. What are the codes to save a copy of this aspx file as a text file?


What exactly are you trying to do? Are you trying to save the fields in the textboxes to a text file? If so, you need to make an IO object, open a file and write the results:
Visual Basic:
'add this to the top of your project
Imports System.IO
'----

'add this function and call it from your button_click event:
Private Function SaveResults() As Boolean
        Try
            Dim myFile As FileInfo
            Dim myPath As String = "Enter_your_file_save_path_here.txt"

            'delete the file if it is already there:
            myFile = New FileInfo(myPath)
            If myFile.Exists Then
                myFile.Delete()
            End If

            Dim mySW As New StreamWriter(myPath)

            mySW.WriteLine("This is the start of the results")
            mySW.WriteLine("VALUE 1: " + textbox1.text)
            mySW.WriteLine("VALUE 2: " + textbox2.text)
            '...
            mySW.WriteLine("This is the end of the results")
            mySW.Close()
            myFile = Nothing
            Return True
        Catch ex As Exception
            If Trace.IsEnabled Then Trace.Write("Error saving Results", ex.ToString())
            Return False
        End Try
    End Function

Also note -- If you are running this from an ASPX page, then you will have to have a writeable directory on your server, unless you impersonate a valid, authorized user.

Good luck!
 
Back
Top