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
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
Can you show the code where you split? FirstName and LastName are the column names right?
ASKER
message = Split(Server.HTMLEncode(Recordset("FullMessage")), " ")
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
With Styles
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
Stylesheet
With BR Tag
FirstName: Jane <br /> LastName: Doe
With Styles
<span style="display: block">FirstName: Jane</span><span style="display: block">LastName: Doe</span>
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>
Stylesheet
.singleline
{
display: block;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.