Reply
Reading the contents of a text file into a textarea
Old 02-15-2007, 12:11 AM Reading the contents of a text file into a textarea
Super Talker

Posts: 107
Hi,

I have a question.

Is there anyway to read a text file into an html <textarea> field in ASP?

I'm creating an online email form in ASP and would love to load a generic letter into a text area that users can edit.

It's not crucial, but it would be great.

Thanks
Donna
DonnaZ is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 02-15-2007, 01:39 AM Re: Reading the contents of a text file into a textarea
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
With an assist from http://www.w3schools.com/asp/showasp.asp?filename=demo_readtextfile :

Code:
Dim F, FS, Letter
Set fs = CreateObject("Scripting.FileSystemObject")
 
Set f = fs.OpenTextFile(Server.MapPath("your_letter_here.txt"), 1)
f.Close
Letter = f.ReadAll
Set f = Nothing
Set fs = Nothing
Response.Write "<textarea name=""letter"">" & Letter & "</textarea>" & vbCrLf
It's always best to write anything to a variable, so that you can manipulate it later if you need to. So I modded that script somewhat. But the basic idea is still there.

Last edited by ADAM Web Design : 02-15-2007 at 01:41 AM.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 02-16-2007, 04:55 PM Re: Reading the contents of a text file into a textarea
Super Talker

Posts: 107
Adam,

Thanks - Donna
DonnaZ is offline
Reply With Quote
View Public Profile
 
Old 02-16-2007, 05:09 PM Re: Reading the contents of a text file into a textarea
Super Talker

Posts: 107
Adam,

I tried your code and it worked. I only had to move the f.close down until after the file read.

This is awesome! I LOVE ASP!

Donna
DonnaZ is offline
Reply With Quote
View Public Profile
 
Old 02-18-2007, 04:46 AM Re: Reading the contents of a text file into a textarea
vivekar's Avatar
Webmaster Talker

Posts: 531
You will also love ASP.NET which is better than ASP.

There is some good IDE (Integrated Development Environment) available for you.
Try learning ASP.NET also.

Happy Learning...
vivekar is offline
Reply With Quote
View Public Profile Visit vivekar's homepage!
 
Old 02-18-2007, 02:50 PM Re: Reading the contents of a text file into a textarea
Super Talker

Posts: 107
I'm not sure how I feel about ASP.NET. I find it easier and faster to code right into ASP.
DonnaZ is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Reading the contents of a text file into a textarea
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14129 seconds with 13 queries