User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,607 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,481 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 1251 | Replies: 3
Reply
Join Date: Sep 2007
Posts: 9
Reputation: Varelei is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Varelei Varelei is offline Offline
Newbie Poster

Help Storing Form Field data in .txt Document (ASP-VB)

  #1  
Nov 10th, 2007
I remember reading something in the past aboout storing form values into strings, then the strings into a .txt document, but that was all about VB 6.0. Could someone give me some source, and even better, an explanation as to how I can make it so the user clicks 'Submit', and their email address (from a input box with name="email" id="email") is stored in a .txt document.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Storing Form Field data in .txt Document (ASP-VB)

  #2  
Nov 10th, 2007
<%@ Import Namespace="System.IO" %>
<script language="vb" runat="server">
  sub Page_Load(sender as Object, e as EventArgs)
    'This will create the file if it doesn't exist, and will also
    'continue to add text to the file. To overwrite the file,
    'just remove the true attribute.
    Dim objStreamWriter As New StreamWriter(FileName, true)

    objStreamWriter.WriteLine(Request.Form("email") & ";" & vbCrLf)
    objStreamWriter.Close()
    
''Now to read the text file and display contents:

    'Get a StreamReader class that can be used to read the file
    Dim objStreamReader as StreamReader
    objStreamReader = File.OpenText(FileName)

    'Now, read the entire file into a string
    Dim contents as String = objStreamReader.ReadToEnd()

    'We may wish to replace carraige returns with <br>s
    lblNicerOutput.Text = contents.Replace(vbCrLf, "<br>")
    
    objStreamReader.Close()
  end sub
</script>
The above post continues to add onto the file, so eventually if 10,000 people fill out your form, you will have 10,000 lines of emails.
Last edited by SheSaidImaPregy : Nov 10th, 2007 at 12:11 pm.
Reply With Quote  
Join Date: Sep 2007
Posts: 9
Reputation: Varelei is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Varelei Varelei is offline Offline
Newbie Poster

Re: Storing Form Field data in .txt Document (ASP-VB)

  #3  
Nov 12th, 2007
Sorry for the late reply, . I've been really busy with my .net work for my course. Thanks for the assistance, this will really help me, as I've not yet been able to read this section of my ebook. I'll add to your reputation again, .
Reply With Quote  
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Storing Form Field data in .txt Document (ASP-VB)

  #4  
Nov 13th, 2007
ha, thank you!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 7:11 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC