Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 31st, 2008, 11:36 PM
Authorized User
 
Join Date: Jan 2008
Location: london, , United Kingdom.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to pepperoni00
Default displaying comments


Dear fiends,
I was trying to put comment section on my website.
The comments are saved in the one text file,from where they are written to and read from webpage.

I use a label control to show the comments cause i have no idea what to use.Comments are shown but are not exactly as seen on text file..
I wanted the comment to look like this, in the page..

Comments:hi how are you?
name:kalsdfsaf
posted on:20/22/23
-----------------------

comment:jkasdfa;kl;lsafdsafasdf
name:asdfsafsafdfsdff
posted on:20/22/93
-----------------------

but i get like this....

Comments:hi how are you?name:
kalsdfsafposted on:20/22/23--
-------------------comment:jk
asdfa;kl;lsafdsafasdfname:asd
fsafsafdfsdff----------------
----

And,What do i do to render the texts to the hypertext as like in this forum?
Reply With Quote
  #2 (permalink)  
Old February 2nd, 2008, 01:41 AM
Authorized User
 
Join Date: Jan 2007
Location: Islamabad, Punjab, Pakistan.
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aliirfan84
Default

What I think is you are missing providing control line feeds. Please use control line feeds if you r not.

Regards,
Ali Irfan
Reply With Quote
  #3 (permalink)  
Old February 2nd, 2008, 01:44 AM
Authorized User
 
Join Date: Jan 2007
Location: Islamabad, Punjab, Pakistan.
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aliirfan84
Default

And please also make sure that you are replacing line feed with <br> when assigning to label.

Regards,
Ali Irfan
Reply With Quote
  #4 (permalink)  
Old February 5th, 2008, 08:06 PM
Authorized User
 
Join Date: Jan 2008
Location: london, , United Kingdom.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to pepperoni00
Default

Ya thanks , but actually


Comments:hi how are you?
name:kalsdfsaf
posted on:20/22/23
-----------------------

comment:jkasdfa;kl;lsafdsafasdf
name:asdfsafsafdfsdff
posted on:20/22/93
-----------------------

is the content of the file which are generated dynamically when a user posts a comment...comments are appended to the end.
Obviously, you wont know where "end of line?" will be, in this case.


got any other idea to show comments dynamically?

Reply With Quote
  #5 (permalink)  
Old February 5th, 2008, 09:21 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

If i understand you correctly, your text file looks like this:
Comments:hi how are you?
name:kalsdfsaf
posted on:20/22/23
-----------------------

comment:jkasdfa;kl;lsafdsafasdf
name:asdfsafsafdfsdff
posted on:20/22/93
-----------------------

but when you read your text file the data gets displayed on your website like this:
Comments:hi how are you?name:
kalsdfsafposted on:20/22/23--
-------------------comment:jk
asdfa;kl;lsafdsafasdfname:asd
fsafsafdfsdff----------------
----

Correct?

Here is your problem, in your text file the end of line and carriage return is represented by these characters: \r\n

The issue is, when you read this information from your text file and display it on your website, a web browser doesn't interpert \r\n so your lines run together!

To remedy this, when you are writing the informaiton to your page do something like this:

StreamReader sr = File.OpenText("<path>");
string foo = sr.ReadToEnd().Replace("\r\n", "<br />");
or
string foo = sr.ReadToEnd().Replace(System.Environment.NewLine, "<br />");

hth.


================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
Reply With Quote
  #6 (permalink)  
Old February 7th, 2008, 10:22 PM
Authorized User
 
Join Date: Jan 2008
Location: london, , United Kingdom.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to pepperoni00
Default

Dear Dparsons,

You absolutely understood me, Thanks to you millions...
I was trying to replace those \ns..but had no idea bout methods.
well, thankd u again.
peace


Reply With Quote
  #7 (permalink)  
Old February 7th, 2008, 10:25 PM
Authorized User
 
Join Date: Jan 2008
Location: london, , United Kingdom.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to pepperoni00
Default

Dear Dparsons,

You absolutely understood me, Thanks to you millions...
I was trying to replace those \ns..but had no idea bout methods.
well, thank u again.
peace


Reply With Quote
  #8 (permalink)  
Old February 7th, 2008, 10:40 PM
Authorized User
 
Join Date: Jan 2008
Location: london, , United Kingdom.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to pepperoni00
Default

Dear Dparsons,

By the way,I think that by employing a textfile to display comments might have a problem.
Like, this file resourse may not be accessible simulatanously when more than two user try to visit the "comment page". i think,I saw "file not accessible,other program or person might be using the file" kinda errors some time..

 Is the above error is true in asp.net 2.0?
 Is it good idea to use .txt file to store comments? or is it what everybody does..

will be thank ful for the guideance..

Reply With Quote
  #9 (permalink)  
Old February 8th, 2008, 09:13 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

By and large, unless there is an extremely good reason, I don't recommend using flat files to store data and would suggest using a Database of some sort.

Yes, only one person can write to the text file at one time so if user A and user B both attempt to submit comments at the same time you can recieve the IO Error that the file is in use.

My suggestion would be to move your comments over to a database of some sort.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
Reply With Quote
  #10 (permalink)  
Old February 12th, 2008, 03:05 PM
Authorized User
 
Join Date: Jan 2008
Location: london, , United Kingdom.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to pepperoni00
Default

thank you so much
Dparsins

peace
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
preapprove comments thuyvncr BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 July 9th, 2007 01:23 AM
Questions, Comments shane.perran BOOK: Beginning SharePoint 2007: Building Team Solutions with MOSS 2007 ISBN: 978-0-470-12449-9 0 May 31st, 2007 05:55 PM
Comments janees ASP.NET 1.0 and 1.1 Professional 1 April 8th, 2007 09:27 PM
Comments in my javascripts 6 xristina Javascript 5 November 4th, 2004 04:08 PM
Comments in my javascripts 4 xristina Javascript 1 November 4th, 2004 10:31 AM



All times are GMT -4. The time now is 01:12 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.