Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After revisiting this issue, I have found that updatepanels were causing the problem.</p> <p>Doing some more testing, I looked into what the string contained using the following code:</p> <pre><code>MsgBox(textbox.Text.Contains(vbCr)) MsgBox(textbox.Text.Contains(vbCrLf)) MsgBox(textbox.Text.Contains(vbNewLine)) MsgBox(textbox.Text.Contains(Environment.Newline)) </code></pre> <p>All four statements returned false. This was tested on the string before sending to the database as well as on the string retrieved from the database. </p> <p>From my point of view, there had to be something on the markup that was removing the line breaks. At first, I thought the Literal, Textbox, and Label controls did something funny to line breaks when retrieved in the code behind. This is not the case (and would be bizarre if Microsoft let this happen).</p> <p>Combing through the code some more, I found that all these controls were inside an UpdatePanel. Remembering my previous negative experiences with UpdatePanels, I then thought that this might just be the culprit. I removed it and lo and behold, the line breaks did not go away in the code. The code I posted just above all returned true.</p> <p>Both pages had the controls for submitting the text and displaying the text inside an UpdatePanel. I found that the line breaks disappeared when retrieving the text from the page. When displaying the text onto the page, the UpdatePanel does not alter the string in any way. The following code ended up working just fine:</p> <pre><code>litMessage.Text = messageBody.Replace(Environment.NewLine, "&lt;br/&gt;") </code></pre> <p>Although I'm still not sure why line breaks were still displayed correctly when using the <code>pre</code> tag or even displaying the retrieved value using a javascript alert box.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload