Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



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

Posts: 116
Trades: 0
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
 
 
Register now for full access!
Old 02-15-2007, 02:39 AM Re: Reading the contents of a text file into a textarea
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)

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

Posts: 116
Trades: 0
Adam,

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

Posts: 116
Trades: 0
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, 05:46 AM Re: Reading the contents of a text file into a textarea
vivekar's Avatar
Webmaster Talker

Posts: 612
Trades: 0
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...
__________________

Please login or register to view this content. Registration is FREE
(Active since 2003) |
Please login or register to view this content. Registration is FREE
vivekar is offline
Reply With Quote
View Public Profile Visit vivekar's homepage!
 
Old 02-18-2007, 03:50 PM Re: Reading the contents of a text file into a textarea
Super Talker

Posts: 116
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.46581 seconds with 12 queries