carriage return [on hold]

Thursday, July 3, 2014

Take the 2-minute tour ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Using C# I have a WPF text box which accepts carriage returns. It saves into the SQL database as a carriage return (I have checked the ASCII on this) but when the application pulls it from the database and into a string and then prints it using HTML with no carriage return. How can I get the string to recognize the carriage return?

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Daniel Kelley, Steve

If this question can be reworded to fit the rules in the help center, please edit the question.

HTML doesn't display new lines based on carriage return, it uses specific markup: <br/>

Quick fix would be to convert all your new lines before rendering it as html...

string html = text.Replace(Environment.NewLine, "<br/>");