avnic
avnic

Reputation: 3361

New Line textbox

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?

Upvotes: 0

Views: 1725

Answers (3)

DanTdr
DanTdr

Reputation: 424

try this : when extracting from database use this :

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

it`s working for me:)

Upvotes: 0

tanascius
tanascius

Reputation: 53964

Did you set the Multiline property?

textBox.Multiline = true;

Upvotes: 2

Donut
Donut

Reputation: 112895

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";

Upvotes: 5

Related Questions