Saturday, March 31, 2012

Text Box to a Database to a Label

Hi

Im fairly new to ASP.NET, im using 2.0.

I am trying to develop a page where the user can enter text into a multiline textbox and then when they click enter the text is stored in a Table in an SQLServer DB.

When the page is reloaded the text that was stored is outputed to a Label.

This works ok except for one small problem when I entertext in the text box which is more than one line IE

"Hello
my
name
is
Graham"

It is displayed in the Label as "Hello my name is Graham"

Does anyone know how to keep the text in the form that it was entered in the textboxwhen it is displayed in the Label?

Other wise I will not be able to have paragraghs etc, just one long string.

Thanks Graham

The text entered in the multiline textbox has crlf (Carriage Return Line Feed) for line breaks. When you display in html, you must replace those with <br /> to achieve the similar layout.

Hope it helps,

Joe

0 comments:

Post a Comment