asp split string with space

Posted on 2011-10-12
Medium Priority
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
  • 2
LVL 48

Expert Comment

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

Author Comment

ID: 36958025
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 75

Expert Comment

by:käµfm³d 👽
ID: 36958034
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

jpaulino earned 2000 total points
ID: 36958044
Try to split by chr(10) or chr(13)

It looks like a break

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

850 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