Displaying texts
Displaying texts
Displaying texts
Displaying texts
Displaying texts
Displaying texts Displaying texts Displaying texts Displaying texts Displaying texts Displaying texts Displaying texts Displaying texts
Displaying texts Displaying texts
Displaying texts
Go Back  Xtreme Visual Basic Talk > > > Displaying texts


Reply
 
Thread Tools Display Modes
  #1  
Old 09-19-2006, 04:54 AM
JustinCase2 JustinCase2 is offline
Junior Contributor
 
Join Date: Apr 2006
Posts: 324
Default Displaying texts


How can I display text from say a plain .txt file in a web page? Or from a .doc file? I am using asp .net 2.0
Reply With Quote
  #2  
Old 09-19-2006, 08:24 AM
wayneph's Avatar
waynephDisplaying texts wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

From a Text File you can use the System.IO name space to read it, and just assign the String to a Label.

A .doc file is a lot more interesting. In this case you're almost going to need to use Word Automation, which isn't good for your server. It would be a lot better if you could save them as Text Files first. (More about Office Automation: http://support.microsoft.com/default...;en-us;q257757)
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
  #3  
Old 09-20-2006, 07:02 AM
JustinCase2 JustinCase2 is offline
Junior Contributor
 
Join Date: Apr 2006
Posts: 324
Default This worked fine, but...

I can display the text from the .txt file. However, another problem occured. The file contains the characters "Æ, Ø, Å" (Norwegian specific letters), but those are removed from the text that is displayed in the bowser. Know how to fix that?
Reply With Quote
  #4  
Old 09-20-2006, 08:24 AM
wayneph's Avatar
waynephDisplaying texts wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

If you go to "View Source" are the characters there? I wonder if it has to do with the character set used on the page. I don't know if ASP.NET is supressing them, or if the browser just won't display them.
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
  #5  
Old 09-20-2006, 08:39 AM
JustinCase2 JustinCase2 is offline
Junior Contributor
 
Join Date: Apr 2006
Posts: 324
Default Well

The characters are removed from the 'view source' aswell. When i click view source, the text is lacking the norwegian letters there too. Does that help?
Reply With Quote
  #6  
Old 09-20-2006, 09:00 AM
wayneph's Avatar
waynephDisplaying texts wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

Well, I've done a little playing with it, but I'm about to have to take off. (taking one of the MCAD tests...)

It looks like it has to do with the Encoding while you are reading in the file. I created a sample file and tried to read it in. Using the default encoder (UTF-8) I got the same thing you did. I changed it around to Unicode, ASCII, etc... and it kept changing a little bit, but never got the characters right.

Do you know what encoding was used to save the file? That will probably help you figure out how to read it.

This is how I was playing with it:
Code:
Label1.Text = My.Computer.FileSystem.ReadAllText(Server.MapPath("text.txt"), System.Text.Encoding.ASCII)

You may also want to try by reading it into a Byte Array, and then using the Encoding options to translate it to the text. Unfortunately as an American that only deals with English, I've never had to really play with or learn the encodings.
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Displaying texts
Displaying texts
Displaying texts Displaying texts
Displaying texts
Displaying texts
Displaying texts Displaying texts Displaying texts Displaying texts Displaying texts Displaying texts Displaying texts
Displaying texts
Displaying texts
 
Displaying texts
Displaying texts
 
-->