asp split string with space

Posted on 2011-10-12
Last Modified: 2012-05-12
I have a column in my sql database with data in it like:
FirstName: Jane
LastName: Doe

when i write it out on the page, it's all one line which is ok but when i try to split it by " " it doesn't.

On the page it looks like:
FirstName: Jane LastName: Doe
Question by:BTMExpert
    LVL 48

    Expert Comment

    Can you show the code where you split? FirstName and LastName are the column names right?

    Author Comment

    message = Split(Server.HTMLEncode(Recordset("FullMessage")), " ")

    Open in new window

    In the db it's displayed as FirstName: JaneLastName: Doe but on the site it's FirstName: Jane LastName: Doe so maybe that's the problem
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    Whitespace is typically consolidated into a single space on web pages. A quick way to display the text on multiple lines is to use a line break tag ( <br /> ). The more extensible way would be to use styles on your text. Here are examples of both:

    With BR Tag
    FirstName: Jane <br /> LastName: Doe

    Open in new window

    With Styles
    <span style="display: block">FirstName: Jane</span><span style="display: block">LastName: Doe</span>

    Open in new window

    Note: I used an inline style here, which is generally regarded as non-extensible. Even more preferable would be to use a stylesheet and keep the style information in the separate CSS file. For instance:

        <link rel="stylesheet" href="stylesheetname.css" />
    <span class="singleline">FirstName: Jane</span><span class="singleline">LastName: Doe</span>

    Open in new window

        display: block;

    Open in new window

    LVL 48

    Accepted Solution

    Try to split by chr(10) or chr(13)

    It looks like a break

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    This video discusses moving either the default database or any database to a new volume.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now