Connecting Tech Pros Worldwide Forums | Help | Site Map

Carriage Return and Response.Write Output Issue

crjunk
Guest
 
Posts: n/a
#1: Oct 11 '06
I have a field in a SQL Server table named DetailedDescription that is
a varchar. If the user adds/edits a detailed description, they do so
in a MulltiLine TextBox control. Therefore, they are able to click
enter on their keyboard and have multiple carriage returns inside the
DetaildDescription.

My problem is that I have another webpage in my project that has the
following statement in it:
Response.Write(drSQL.Item("DetailDescription")).

If the user created a record in the following format:
HELLO
WORLD

It is now displayed as:
HELLO WORLD

Is there something I can add to my Response.Write statement so that the
carriage returns are "written" so that the output is in the following
format:
HELLO
WORLD

I hope this makes sense.


Thanks,
CR Junk


gomer
Guest
 
Posts: n/a
#2: Oct 11 '06

re: Carriage Return and Response.Write Output Issue


Response.Write(Replace(vbCrLf, "<br>"))



"crjunk" <crjunk@earthlink.netwrote in message
news:1160579676.405500.219170@c28g2000cwb.googlegr oups.com...
Quote:
>I have a field in a SQL Server table named DetailedDescription that is
a varchar. If the user adds/edits a detailed description, they do so
in a MulltiLine TextBox control. Therefore, they are able to click
enter on their keyboard and have multiple carriage returns inside the
DetaildDescription.
>
My problem is that I have another webpage in my project that has the
following statement in it:
Response.Write(drSQL.Item("DetailDescription")).
>
If the user created a record in the following format:
HELLO
WORLD
>
It is now displayed as:
HELLO WORLD
>
Is there something I can add to my Response.Write statement so that the
carriage returns are "written" so that the output is in the following
format:
HELLO
WORLD
>
I hope this makes sense.
>
>
Thanks,
CR Junk
>

Bob Barrows [MVP]
Guest
 
Posts: n/a
#3: Oct 11 '06

re: Carriage Return and Response.Write Output Issue


crjunk wrote:
Quote:
I have a field in a SQL Server table named DetailedDescription that is
a varchar. If the user adds/edits a detailed description, they do
so in a MulltiLine TextBox control. Therefore, they are able to
click enter on their keyboard and have multiple carriage returns
inside the DetaildDescription.
>
My problem is that I have another webpage in my project that has the
following statement in it:
Response.Write(drSQL.Item("DetailDescription")).
>
If the user created a record in the following format:
HELLO
WORLD
>
It is now displayed as:
HELLO WORLD
>
Is there something I can add to my Response.Write statement so that
the carriage returns are "written" so that the output is in the
following format:
HELLO
WORLD
>
A. Display the data in a textarea instead of response.writing it into
the html
B. Surround the data in <PRE></PREtags
C. Replace the carriage returns with <BR- this is basic html.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


crjunk
Guest
 
Posts: n/a
#4: Oct 13 '06

re: Carriage Return and Response.Write Output Issue


Thanks for the responses. I ended up using Gomer's suggeetion.

CR Junk

Firas
Guest
 
Posts: n/a
#5: Oct 17 '06

re: Carriage Return and Response.Write Output Issue


Hi, if i were you, i would use the same as Gomer's but with little
modification
Response.Write(replace(drSQL.Item("DetailDescripti on"),chr(13),"<BR>")

what i did is that i replaced the vbCrLf to chr(13), because the vbCrLf
is combination of chr(13) and chr(10), so what if the user had used a
format that he only included the chr(13), then if you use the vbCrLf it
will not work, because using the vbCrlf will look for the two at once
which only one is available. And by the way, according to me testings,
chr(13) is required for the enter more than the chr(10) which means
chr(10) is always to occure.
And if you still want to use his advice, then use it this way: use vbCr
instead of chr(13)


Best Regards
Firas S Assaad
crjunk wrote:
Quote:
Thanks for the responses. I ended up using Gomer's suggeetion.
>
CR Junk
Anthony Jones
Guest
 
Posts: n/a
#6: Oct 17 '06

re: Carriage Return and Response.Write Output Issue



"Firas" <firas489@gmail.comwrote in message
news:1161052940.189145.108950@m7g2000cwm.googlegro ups.com...
Quote:
Hi, if i were you, i would use the same as Gomer's but with little
modification
Response.Write(replace(drSQL.Item("DetailDescripti on"),chr(13),"<BR>")
>
what i did is that i replaced the vbCrLf to chr(13), because the vbCrLf
is combination of chr(13) and chr(10), so what if the user had used a
format that he only included the chr(13), then if you use the vbCrLf it
will not work, because using the vbCrlf will look for the two at once
which only one is available. And by the way, according to me testings,
chr(13) is required for the enter more than the chr(10) which means
chr(10) is always to occure.
And if you still want to use his advice, then use it this way: use vbCr
instead of chr(13)
>
There are two end-of-line markers in common use. CRLF or just plain LF.
I've not come across many (in fact never have) systems that only use CR.
What tests did you use to discover that CR on it's own is more common or
indeed ever happens at all?

My solution BTW is :-

Replace(Replace(Server.HTMLEncode(s), vbCR, ""), vbLF, "<br />")



Quote:
>
Best Regards
Firas S Assaad
crjunk wrote:
Quote:
Thanks for the responses. I ended up using Gomer's suggeetion.

CR Junk
>

XML noob
Guest
 
Posts: n/a
#7: Oct 17 '06

re: Carriage Return and Response.Write Output Issue


we're talking about someone hitting the enter key in text area on a web
page...
how would this ever be translated into anything other than crlf??


"Anthony Jones" <Ant@yadayadayada.comwrote in message
news:eN9yaOe8GHA.4476@TK2MSFTNGP04.phx.gbl...
Quote:
>
"Firas" <firas489@gmail.comwrote in message
news:1161052940.189145.108950@m7g2000cwm.googlegro ups.com...
Quote:
>Hi, if i were you, i would use the same as Gomer's but with little
>modification
>Response.Write(replace(drSQL.Item("DetailDescript ion"),chr(13),"<BR>")
>>
>what i did is that i replaced the vbCrLf to chr(13), because the vbCrLf
>is combination of chr(13) and chr(10), so what if the user had used a
>format that he only included the chr(13), then if you use the vbCrLf it
>will not work, because using the vbCrlf will look for the two at once
>which only one is available. And by the way, according to me testings,
>chr(13) is required for the enter more than the chr(10) which means
>chr(10) is always to occure.
>And if you still want to use his advice, then use it this way: use vbCr
>instead of chr(13)
>>
>
There are two end-of-line markers in common use. CRLF or just plain LF.
I've not come across many (in fact never have) systems that only use CR.
What tests did you use to discover that CR on it's own is more common or
indeed ever happens at all?
>
My solution BTW is :-
>
Replace(Replace(Server.HTMLEncode(s), vbCR, ""), vbLF, "<br />")
>
>
>
>
Quote:
>>
>Best Regards
>Firas S Assaad
>crjunk wrote:
Quote:
Thanks for the responses. I ended up using Gomer's suggeetion.
>
CR Junk
>>
>
>

Bob Barrows [MVP]
Guest
 
Posts: n/a
#8: Oct 17 '06

re: Carriage Return and Response.Write Output Issue


I think that's exactly Anthony's question. Perhaps Firas is aware of a
browser that will use vbCr instead of vbCrLf.

XML noob wrote:
Quote:
we're talking about someone hitting the enter key in text area on a
web page...
how would this ever be translated into anything other than crlf??
>
>
"Anthony Jones" <Ant@yadayadayada.comwrote in message
news:eN9yaOe8GHA.4476@TK2MSFTNGP04.phx.gbl...
Quote:
>>
>"Firas" <firas489@gmail.comwrote in message
>news:1161052940.189145.108950@m7g2000cwm.googlegr oups.com...
Quote:
>>Hi, if i were you, i would use the same as Gomer's but with little
>>modification
>>>
Response.Write(replace(drSQL.Item("DetailDescripti on"),chr(13),"<BR>")
Quote:
Quote:
Quote:
>>>
>>what i did is that i replaced the vbCrLf to chr(13), because the
>>vbCrLf is combination of chr(13) and chr(10), so what if the user
>>had used a format that he only included the chr(13), then if you
>>use the vbCrLf it will not work, because using the vbCrlf will look
>>for the two at once which only one is available. And by the way,
>>according to me testings, chr(13) is required for the enter more
>>than the chr(10) which means chr(10) is always to occure.
>>And if you still want to use his advice, then use it this way: use
>>vbCr instead of chr(13)
>>>
>>
>There are two end-of-line markers in common use. CRLF or just plain
>LF. I've not come across many (in fact never have) systems that only
>use CR. What tests did you use to discover that CR on it's own is
>more common or indeed ever happens at all?
>>
>My solution BTW is :-
>>
>Replace(Replace(Server.HTMLEncode(s), vbCR, ""), vbLF, "<br />")
>>
>>
>>
>>
Quote:
>>>
>>Best Regards
>>Firas S Assaad
>>crjunk wrote:
>>>Thanks for the responses. I ended up using Gomer's suggeetion.
>>>>
>>>CR Junk
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Anthony Jones
Guest
 
Posts: n/a
#9: Oct 17 '06

re: Carriage Return and Response.Write Output Issue



"XML noob" <leav@s.comwrote in message
news:OxW0$Kg8GHA.3760@TK2MSFTNGP02.phx.gbl...
Quote:
we're talking about someone hitting the enter key in text area on a web
page...
how would this ever be translated into anything other than crlf??
>
If you pass stuff around via XML you will find CRLFs being converted to just
LFs.
Quote:
>
"Anthony Jones" <Ant@yadayadayada.comwrote in message
news:eN9yaOe8GHA.4476@TK2MSFTNGP04.phx.gbl...
Quote:

"Firas" <firas489@gmail.comwrote in message
news:1161052940.189145.108950@m7g2000cwm.googlegro ups.com...
Quote:
Hi, if i were you, i would use the same as Gomer's but with little
modification
Response.Write(replace(drSQL.Item("DetailDescripti on"),chr(13),"<BR>")
>
what i did is that i replaced the vbCrLf to chr(13), because the vbCrLf
is combination of chr(13) and chr(10), so what if the user had used a
format that he only included the chr(13), then if you use the vbCrLf it
will not work, because using the vbCrlf will look for the two at once
which only one is available. And by the way, according to me testings,
chr(13) is required for the enter more than the chr(10) which means
chr(10) is always to occure.
And if you still want to use his advice, then use it this way: use vbCr
instead of chr(13)
>
There are two end-of-line markers in common use. CRLF or just plain LF.
I've not come across many (in fact never have) systems that only use CR.
What tests did you use to discover that CR on it's own is more common or
indeed ever happens at all?

My solution BTW is :-

Replace(Replace(Server.HTMLEncode(s), vbCR, ""), vbLF, "<br />")



Quote:
>
Best Regards
Firas S Assaad
crjunk wrote:
Thanks for the responses. I ended up using Gomer's suggeetion.

CR Junk
>
>
>

Closed Thread


Similar ASP / Active Server Pages bytes