944,165 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 13109
  • ASP.NET RSS
Sep 22nd, 2006
0

Replacing "Enter" in textBox

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Stivi is offline Offline
26 posts
since Jun 2005
Sep 22nd, 2006
0

Re: Replacing "Enter" in textBox

Try String.Replace(Environment.NewLine, "<br>")
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Sep 22nd, 2006
0

Re: Replacing "Enter" in textBox

chr13
or
VbCrLf
Last edited by extofer; Sep 22nd, 2006 at 8:26 pm.
Reputation Points: 8
Solved Threads: 6
Posting Whiz in Training
extofer is offline Offline
239 posts
since Aug 2005
Sep 23rd, 2006
0

Re: Replacing "Enter" in textBox

Click to Expand / Collapse  Quote originally posted by tgreer ...
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
Last edited by Stivi; Sep 23rd, 2006 at 9:33 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
Stivi is offline Offline
26 posts
since Jun 2005
Sep 27th, 2006
0

Re: Replacing "Enter" in textBox

Try this:

ASP.NET Syntax (Toggle Plain Text)
  1. Me.MyLiteral.Text = Me.MyTextBox.Text.Replace(ControlChars.NewLine, "<br />")
Reputation Points: 12
Solved Threads: 11
Junior Poster in Training
ManicCW is offline Offline
95 posts
since Nov 2005
Nov 10th, 2008
0

Re: Replacing "Enter" in textBox

ASP.NET Syntax (Toggle Plain Text)
  1. string text = txtBody.Text.Replace(Environment.NewLine, "<br />");
Worked fine for me when putting it into a new MailMessage:

ASP.NET Syntax (Toggle Plain Text)
  1. message.From = new MailAddress(txtFrom.Text);
  2. message.Sender = new MailAddress(txtFrom.Text);
  3. message.To.Add(txtTo.Text);
  4. message.Subject = txtSubject.Text;
  5. message.IsBodyHtml = true;
  6. string text = txtBody.Text.Replace(Environment.NewLine, "<br />");
  7. message.Body = text;

-Tom
Last edited by navyjax2; Nov 10th, 2008 at 5:06 pm.
Reputation Points: 11
Solved Threads: 1
Junior Poster in Training
navyjax2 is offline Offline
52 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Final Project Ideas Require
Next Thread in ASP.NET Forum Timeline: Repeater control on Mac PC





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC