Multiline textbox drop the char return when saved to sql

C

CalSun

Hi all,
I try to save a multiline textbox into an sql field (nvarchar(1024)). As I
read it out and display, the text drops all the linefeed char.
Is there a way to cure this? Thank you all for help.

--Calsun
 
C

CalSun

Thanks for the tips.
I tried it and it didn't work. I decoded before saving and encoded back, but
the linefeed char still missing.

Your help please. Thanks
--CS
 
P

Peter Rilling

When you render the content, it renders it as HTML text. The problem is
that the browser ignores whitespace. Before rendering it, you will need to
change all linefeeds to <br>.
 
C

CalSun

Thanks Peter,
I'll try that.
By the way, what is the value of the linefeed char inside a multiline
textbox?
thanks
--CS
 
C

CalSun

Thank you all for helping.
I just converted ctrlf into <br> before saving. That works fine. However, it
won't look good if I query and display the text in a non-html environment.
--CS
 
G

Guest

When rendering in non-html just use the following concept to deal with the BR
tags:

// C# Code
string x = "some text<br>some more text<br>blah blah blah";
x = x.Replace("<br>", "\r\n");

' VB Code
Dim x as string = "some text<br>some more text<br>blah blah blah"
x = x.Replace("<br>", vbCrLf)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top