Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-13-2005, 06:26 AM   PM User | #1
jaywhy13
Regular Coder

 
Join Date: Dec 2004
Location: Jamaica
Posts: 592
Thanks: 2
Thanked 0 Times in 0 Posts
jaywhy13 is an unknown quantity at this point
Lightbulb Server side alternative to "<pre>"

Okay here is the problem I have.

Users enter data into a textbox... and I write it to my database. However when I retrieve the data from my database, the layout is completely changed. That is, where the user pressed enter and so on.... all the text is jumbled.

I have tried my luck with the "<pre>" tag but that gave me one everlasting line that streched out my page a few screen sizes to the right depending on how long the line was?

It was suggested to me that i need to forget the "<pre>" tag and use a server side method to store/display the code in such a way that it appears as it does in this forum. That is, no matter how much text we type... wherever we press enter it is conserved in the display of the post.....
jaywhy13 is offline   Reply With Quote
Old 01-13-2005, 03:37 PM   PM User | #2
ghell
Senior Coder

 
Join Date: Apr 2003
Location: England
Posts: 1,192
Thanks: 5
Thanked 13 Times in 13 Posts
ghell is on a distinguished road
im not really sure what your question is but the vbNewLine constant is used for a new line in the source, <br> is used for a newline in the page..

eg:

'hello
'how are you?
strString = "hello" & vbNewline & "how are you?"

'hello<br>how are you?
strHTMLOutput = Replace(strString, vbNewLine, "<br>")

'hello<br>
'how are you?
strPreOutput = Replace(strString, vbNewLine, "<br>" & vbNewLine)
__________________
My tech/code blog
ghell is offline   Reply With Quote
Old 01-13-2005, 04:18 PM   PM User | #3
jaywhy13
Regular Coder

 
Join Date: Dec 2004
Location: Jamaica
Posts: 592
Thanks: 2
Thanked 0 Times in 0 Posts
jaywhy13 is an unknown quantity at this point
Thumbs up you the boss!!!!!

Yo ghell, just kno that u the boss! Thanks man.... i've spent weeks trying to get around this problem.

I've tried asking the same question different ways in different forums tryin to get a response and all sounded good at face value but thnx alot man!!!!


Works lke a charm
jaywhy13 is offline   Reply With Quote
Old 01-14-2005, 09:43 AM   PM User | #4
ghell
Senior Coder

 
Join Date: Apr 2003
Location: England
Posts: 1,192
Thanks: 5
Thanked 13 Times in 13 Posts
ghell is on a distinguished road
yaaay

on a sidenote, i didnt mention though that pre does other things, it keeps whitespace and writes in a monospace font

to keep whitespace replace " " with "&nbsp;" and similar with tabs (4 or 8 spaces, or theres probably a tab in the iso character table somewhere)

note: one space is fine, so
Code:
" " = " "
"   " = " "
" &nbsp; " = "   "
so it would be more efficient to just replace "  " with " &nbsp;"
i think

monospace fonts can be done by using a monospace font (ie courier [use this its the standard one], courier new, lucidia console) or typewriter tags (<tt>..</tt>)
__________________
My tech/code blog
ghell is offline   Reply With Quote
Old 01-14-2005, 10:54 AM   PM User | #5
Sayonara
Regular Coder

 
Sayonara's Avatar
 
Join Date: Oct 2004
Location: UK
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Sayonara is an unknown quantity at this point
If your users are going to be able to edit these fields later, you might want to save both their submitted original, and the 'fixed' version in your database.

When they edit the record, you serve the original version they typed to the editing page. Otherwise you'll be sending the fixed version, and unless you reverse the changes you made the textarea the user sees will be full of code they don't recognise.
__________________
Quote:
Originally Posted by liorean
Just remember that you code for the user, and the user visits you because what you code is good.
Sayonara is offline   Reply With Quote
Old 01-14-2005, 12:13 PM   PM User | #6
jaywhy13
Regular Coder

 
Join Date: Dec 2004
Location: Jamaica
Posts: 592
Thanks: 2
Thanked 0 Times in 0 Posts
jaywhy13 is an unknown quantity at this point
thanks i'll see how that works.... i'm a gonna give that a try
jaywhy13 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 03:45 AM.


Advertisement
Log in to turn off these ads.