Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
How do I get a carriage return from input text
Old 03-09-2006, 05:13 AM How do I get a carriage return from input text
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
Hi

I have a text area returveing input form the user.

Although the user can press return to create a new paragraph and htis show in the text area. When i write it the database and later output it to a web page, the carriage return is not there.

Could someone please tell me how i write the carriage returns from a text area to a database field with the input text.

cheers
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 03-09-2006, 05:20 AM Re: How do I get a carriage return from input text
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
If you look at the source code, the carrage returns will be there. They just don't render in HTML because they're considered whitespace. What you need to do is replace them with a <br /> tag.

Response.Write(Replace(MyDBValuue, Chr(13), "<br />"))
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 03-13-2006, 10:37 AM Re: How do I get a carriage return from input text
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
THANKS
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Old 03-13-2006, 03:07 PM Re: How do I get a carriage return from input text
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Although chr(13) will work in most cases, I find vbCrLf works more often (Visual Basic Carriage Return/Line Feed). I'll also use it when outputting HTML to put a line break in where I want it.

e.g.
Code:
Response.Write "<div>Some Code</div>" & vbCrLf
It's a wonderful thing, that vbCrLf is.

The other thing you may wish to implement is something to ensure that double carriage returns are paragraphed.

e.g.
Code:
Text_Input = Request.Form ("yourtextarea")
if Text_Input <> "" then ' Replace won't work on null entries.
Text_Input = Replace (Text_Area, vbCrLf & vbCrLf, "</p><p>")
Text_Input = Replace (Text_Input, vbCrLf, "<br />")
Text_Input 
end if
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 03-13-2006, 03:07 PM Re: How do I get a carriage return from input text
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Although chr(13) will work in most cases, I find vbCrLf works more often (Visual Basic Carriage Return/Line Feed). I'll also use it when outputting HTML to put a line break in where I want it.

e.g.
Code:
Response.Write "<div>Some Code</div>" & vbCrLf
It's a wonderful thing, that vbCrLf is.

The other thing you may wish to implement is something to ensure that double carriage returns are paragraphed.

e.g.
Code:
Text_Input = Request.Form ("yourtextarea")
if Text_Input <> "" then ' Replace won't work on null entries.
Text_Input = Replace (Text_Area, vbCrLf & vbCrLf, "</p><p>")
Text_Input = Replace (Text_Input, vbCrLf, "<br />")
Text_Input = "<p>" 
end if
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 03-13-2006, 03:08 PM Re: How do I get a carriage return from input text
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Although chr(13) will work in most cases, I find vbCrLf works more often (Visual Basic Carriage Return/Line Feed). I'll also use it when outputting HTML to put a line break in where I want it.

e.g.
Code:
Response.Write "<div>Some Code</div>" & vbCrLf
It's a wonderful thing, that vbCrLf is.

The other thing you may wish to implement is something to ensure that double carriage returns are paragraphed.

e.g.
Code:
Text_Input = Request.Form ("yourtextarea")
if Text_Input <> "" then ' Replace won't work on null entries.
Text_Input = Replace (Text_Area, vbCrLf & vbCrLf, "</p><p>")
Text_Input = Replace (Text_Input, vbCrLf, "<br />")
Text_Input = "<p>" & Text_Input & "</p>" ' This is done in case you have multiple paragraphs.  If not, it's still safe coding.
end if
Play with that. It should get you where you want to go.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 03-13-2006, 03:08 PM Re: How do I get a carriage return from input text
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Weird. It submitted 3 times.

Any mods out there that can fix that? I didn't do that, I swear.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to How do I get a carriage return from input text
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30948 seconds with 12 queries