Last week, I need to make a simply web form that sends the information via email after the client hits the Submit button. Some of the texbox in this form are at multiline mode, which won't display the hard return on an either text or html mode email body. I did goolge and thought there might be some easy solution out there but unlucky didn't find anything useful. So I look up the MSDN document and based on the information I got, here is what I did:
// get the char code of ENTER
char[] chars;
byte[] bytes = new byte[] {13};
System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();
int charCount = ascii.GetCharCount(bytes,0,1);
chars = new char[charCount];
int charDecodedCount = ascii.GetChars(bytes,0,1,chars,0);
...
msgSearch.Text = msgSearch.Text.Replace(chars[0].ToString(), "<br>");
Basically, the first part of code is for getting the char for hard return (ASCII code 13), the second part is for replacing the hard return char in the text box to html return tag “<br>“. Works perfectly.