Link to home
Start Free TrialLog in
Avatar of BTMExpert
BTMExpert

asked on

asp split string with space

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
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

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

ASKER

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

Markup
...

<head>
    <link rel="stylesheet" href="stylesheetname.css" />
</head>

...

<span class="singleline">FirstName: Jane</span><span class="singleline">LastName: Doe</span>

Open in new window


Stylesheet
.singleline
{
    display: block;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial