Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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?
Posted
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:

'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!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...