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

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

chr13
or
VbCrLf

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

Try this:

Me.MyLiteral.Text = Me.MyTextBox.Text.Replace(ControlChars.NewLine, "<br />")
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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.