0

Hi,

Is there some way how to repalce "Enter" character on the end of line (for example in the textBox) with HTML tag </br>, so I can use it then in Literal?

Steve

5
Contributors
5
Replies
7
Views
10 Years
Discussion Span
Last Post by navyjax2
0

Try String.Replace(Environment.NewLine, "<br>")

Hi,

I've tried this but it's not working... I've also tried TextBox1.Text.Replace("\r\n", "</br>"); or TextBox1.Text.Replace(Convert.ToString((char)13), "</br>"); but it's not working too... So simple thing is so hard to do :cheesy: By the way - it's C# code.


Steve

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

Worked fine for me when putting it into a new MailMessage:

message.From = new MailAddress(txtFrom.Text);
            message.Sender = new MailAddress(txtFrom.Text);
            message.To.Add(txtTo.Text);
            message.Subject = txtSubject.Text;
            message.IsBodyHtml = true;
            string text = txtBody.Text.Replace(Environment.NewLine, "<br />");
            message.Body = text;

-Tom

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.