ENTER key in TextBox in ASP.NET 2.0

  • Thread starter Thread starter Benson Wong
  • Start date Start date
B

Benson Wong

I add a TextBox with TextMode="MultiLine" so that I can input multilines to
the textbox. That's fine.

When user input <ENTER> as a new line, it is ok during input to the textbox,
but not ok when the textbox content is saved to database (<ENTER> character
seems to be ignored, no new line appears when the data is saved to
database).

Any hints.
Benson
 
How do you know ? Newlines could be honored or not depending how you display
those data. In particular keep in mind that newlines are not significant
when using HTML i.e. you'll have to replace those with the br tag to see a
visible effect.
 
When you show the data on the page replace carriage returns with <br/>

myText.Replace ("\r\n", "<br/>");
 
Back
Top