Results 1 to 6 of 6

Thread: ASP- Text formatting from database

  1. #1

    Thread Starter
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188

    ASP- Text formatting from database

    Hey All,

    I store some large text fields in my database. When i view it in a ASP page it loses all it's formatting in particular Enters are missing.

    Whats an easy way to keep the text formatted as like it was when it went in?

    cheers for any help
    b

  2. #2
    Addicted Member rdove's Avatar
    Join Date
    Dec 2002
    Location
    Indianapolis
    Posts
    251
    I'm sure there is a better way..but off the top of my head:

    Code:
    Message = Replace(request.form("txtMessage"), vbcrlf, "<br>")
    
    rs("Message") = Message
    ~Ryan





    Have I helped you? Please Rate my posts.

  3. #3

    Thread Starter
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    yeah i use that now i was hoping there'd be a server function or something that someone knows of??

    thanks rdove!

  4. #4
    Lively Member
    Join Date
    Nov 2001
    Location
    Behind you...
    Posts
    88
    I'n not sure that I understand the problem. I have a page which displays text from a MEMO type field in a MS Access database! If the user has inputted an ENTER keypress then the ENTER is remembered. It also works with "<br>" so instead of writing a lot of functions maybe you should try to change the format of your field to MEMO insted of CHAR or VARCHAR or whatever you are using...

    Enjoy
    MC
    Enjoy...
    ----
    If something is hard to do then it aint worth doing!!

  5. #5
    Addicted Member rdove's Avatar
    Join Date
    Dec 2002
    Location
    Indianapolis
    Posts
    251
    I have a memo field in my Access DB and it doesn't keep the formatting....
    ~Ryan





    Have I helped you? Please Rate my posts.

  6. #6
    Addicted Member
    Join Date
    Aug 2000
    Location
    Pennsylvania, USA
    Posts
    168
    Remember that a carriage return in text does not translate to a carriage return in HTML. You either have to replace them with <br>'s, as someone metioned earlier, or you have to use the
    <pre> tag for preformatted text.

    VB Code:
    1. Response.write Replace(Recordset.Fields.item("message").value, vbCrLf, "<br>")
    2.  
    3. or . . .
    4.      Response.write "<pre>" & Recordset.Fields.item("message").value & "</pre>"
    Wydok

    "It would appear that we have reached the limits of what it is possible to achieve with computer technology, although one should be careful with such statements, as they tend to sound pretty silly in 5 years."

    -John Von Neumann ca. 1949

Posting Permissions

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



Click Here to Expand Forum to Full Width