tags:

views:

218

answers:

3

I have a comment box that users can fill and saving the text in a MySQL database:

When a users fills text in my textbox with a backslash (\n) it shows in the text box without the new line.

For example, the user enters:

Hi everyone!

Me

The Textbox displays:

Hi Everyone!Me

What am I doing wrong?

+2  A: 

Did you set the Multiline property?

textBox.Multiline = true;
tanascius
+5  A: 

Use Environment.NewLine instead of "\n" (or at least "\r\n", since this is what Environment.NewLine contains on non-Unix platforms anyway).

Also, make sure your TextBox's MultiLine property is set to true.

myTextBox.MultiLine = true;
myTextBox.Text = "hi," + Environment.NewLine + "ALL";
Donut
the newline comment is only handy when setting text in code. So you should capture the keypresses and when the last command is \r\n then replace that with Environment.NewLine
PoweRoy
A: 

try this : when extracting from database use this :

str_replace("\n",'<br />',$databasefield)

it`s working for me:)

DanTdr