I have a multiline Textbox that I acts as a description field. Large amounts of information can be added to this textbox with spacing and returns. In a Paragraph format. When i display this text later on as a Label I lose all my formatting and it turns into a wall of text. Is there anything i can do to keep the original formatting?
var customerInfo = GetCustomerInfo(itemid);
if (customerInfo != null)
{
ItemID.Text = customerInfo.ItemID.ToString();
Description.Text = customerInfo.Description;
}
The page Source looks like this
This is a test
this is a test
this is a test
1. test
2. test
3. test
4. tes
The Label/literal look like this
This is a test this is a test this is a test 1. test 2. test 3. test 4. tes
When you display formatted text in HTML, it’s not shown formatted because HTML has other methods of formatting text. All formatting characters (line breaks, tabs, et.c.) counts as spaces in HTML, so it will just be shown as a massive block of text.
To show the text formatted in HTML you have to translate the formatting into what HTML uses for formatting, for example: