Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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.....

  • #2
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    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)

  • #3
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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

  • #4
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    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>)

  • #5
    Regular Coder
    Join Date
    Oct 2004
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thanks i'll see how that works.... i'm a gonna give that a try


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •