Home All Groups Group Topic Archive Search About

Carriage Return and Response.Write Output Issue

Author
11 Oct 2006 3:14 PM
crjunk
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

Author
11 Oct 2006 3:21 PM
gomer
Response.Write(Replace(vbCrLf, "<br>"))



Show quoteHide quote
"crjunk" <crj***@earthlink.net> wrote in message
news:1160579676.405500.219170@c28g2000cwb.googlegroups.com...
>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
>
Are all your drivers up to date? click for free checkup

Author
11 Oct 2006 3:27 PM
Bob Barrows [MVP]
crjunk wrote:
Show quoteHide 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></PRE> tags
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.
Author
13 Oct 2006 12:45 PM
crjunk
Thanks for the responses.  I ended up using Gomer's suggeetion.

CR Junk
Author
17 Oct 2006 2:42 AM
Firas
Hi, if i were you, i would use the same as Gomer's but with little
modification
Response.Write(replace(drSQL.Item("DetailDescription"),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:
Show quoteHide quote
> Thanks for the responses.  I ended up using Gomer's suggeetion.
>
> CR Junk
Author
17 Oct 2006 11:58 AM
Anthony Jones
Show quote Hide quote
"Firas" <firas***@gmail.com> wrote in message
news:1161052940.189145.108950@m7g2000cwm.googlegroups.com...
> Hi, if i were you, i would use the same as Gomer's but with little
> modification
> Response.Write(replace(drSQL.Item("DetailDescription"),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 :-

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




>
> Best Regards
> Firas S Assaad
> crjunk wrote:
> > Thanks for the responses.  I ended up using Gomer's suggeetion.
> >
> > CR Junk
>
Author
17 Oct 2006 3:41 PM
XML noob
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??


Show quoteHide quote
"Anthony Jones" <A**@yadayadayada.com> wrote in message
news:eN9yaOe8GHA.4476@TK2MSFTNGP04.phx.gbl...
>
> "Firas" <firas***@gmail.com> wrote in message
> news:1161052940.189145.108950@m7g2000cwm.googlegroups.com...
>> Hi, if i were you, i would use the same as Gomer's but with little
>> modification
>> Response.Write(replace(drSQL.Item("DetailDescription"),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 />")
>
>
>
>
>>
>> Best Regards
>> Firas S Assaad
>> crjunk wrote:
>> > Thanks for the responses.  I ended up using Gomer's suggeetion.
>> >
>> > CR Junk
>>
>
>
Author
17 Oct 2006 5:14 PM
Bob Barrows [MVP]
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:
Show quoteHide 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" <A**@yadayadayada.com> wrote in message
> news:eN9yaOe8GHA.4476@TK2MSFTNGP04.phx.gbl...
>>
>> "Firas" <firas***@gmail.com> wrote in message
>> news:1161052940.189145.108950@m7g2000cwm.googlegroups.com...
>>> Hi, if i were you, i would use the same as Gomer's but with little
>>> modification
>>>
Response.Write(replace(drSQL.Item("DetailDescription"),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 />")
>>
>>
>>
>>
>>>
>>> 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.
Author
17 Oct 2006 10:02 PM
Anthony Jones
"XML noob" <l***@s.com> wrote in message
news:OxW0$Kg8GHA.3760@TK2MSFTNGP02.phx.gbl...
> 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.

Show quoteHide quote
>
> "Anthony Jones" <A**@yadayadayada.com> wrote in message
> news:eN9yaOe8GHA.4476@TK2MSFTNGP04.phx.gbl...
> >
> > "Firas" <firas***@gmail.com> wrote in message
> > news:1161052940.189145.108950@m7g2000cwm.googlegroups.com...
> >> Hi, if i were you, i would use the same as Gomer's but with little
> >> modification
> >> Response.Write(replace(drSQL.Item("DetailDescription"),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 />")
> >
> >
> >
> >
> >>
> >> Best Regards
> >> Firas S Assaad
> >> crjunk wrote:
> >> > Thanks for the responses.  I ended up using Gomer's suggeetion.
> >> >
> >> > CR Junk
> >>
> >
> >
>
>

Bookmark and Share