Solved

Read Text File, populate HTML TextArea

Posted on 2009-04-06
5
1,795 Views
Last Modified: 2012-05-06
I have a tab delimited text file.  I want to open up an HTML page and take this text file and populate a text area in that  HTML page. How do I go about doing this?
0
Comment
Question by:MichelleLacy
  • 3
  • 2
5 Comments
 
LVL 29

Expert Comment

by:anarki_jimbel
ID: 24082039
Where is you file is located?

You can't read a file on a clien computer from the page (through code).
0
 

Author Comment

by:MichelleLacy
ID: 24083290
The file will be saved in My Documents.
0
 
LVL 29

Expert Comment

by:anarki_jimbel
ID: 24083775
OK, I don't understand. You want to OPEN a file on a client computer? Or you want to SAVE it?
Anyway, as I already told, keep in mind that you can't read/write files on a client computer.
0
 

Author Comment

by:MichelleLacy
ID: 24085979
The program will run a user's computer.  The user has save a file in a specified format on their computer.  The program will look for this file, read the contents and paste it into a text area.  So let's say I am the user.   The text file is on my computer.  I have a text file with two columns.  I want to copy the contents of this file and paste it into a text area of an html page.
 
0
 

Accepted Solution

by:
MichelleLacy earned 0 total points
ID: 24147748
I found the solution:
1st using C# FileStream open file, then read it:
FileStream fileStream = new FileStream(@"c:\file.txt", FileMode.Open, FileAccess.Read);
Then set up an event to copy the text to the clipboard Clipboard.SetText(txtClipboard.Text), then ...whatever.Text = Clipboard.GetText();

Finally I found a method in Javascript, but I bet you can do it in C# as well, buyt this seemed more straightforward.  Open the URL link, grab the text from the clipboard and paste into into the textarea of the html page
<script type="text/javascript">
function PasteFromClipboard()

{

   document.Form1.txtArea.focus();

   PastedText = document.Form1.txtArea.createTextRange();

   PastedText.execCommand("Paste");

}

</script>
 
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now