Replacing "Enter" in textBox

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2005
Posts: 26
Reputation: Stivi is an unknown quantity at this point 
Solved Threads: 0
Stivi's Avatar
Stivi Stivi is offline Offline
Light Poster

Replacing "Enter" in textBox

 
0
  #1
Sep 22nd, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Replacing "Enter" in textBox

 
0
  #2
Sep 22nd, 2006
Try String.Replace(Environment.NewLine, "<br>")
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 239
Reputation: extofer is an unknown quantity at this point 
Solved Threads: 5
extofer's Avatar
extofer extofer is offline Offline
Posting Whiz in Training

Re: Replacing "Enter" in textBox

 
0
  #3
Sep 22nd, 2006
chr13
or
VbCrLf
Last edited by extofer; Sep 22nd, 2006 at 8:26 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 26
Reputation: Stivi is an unknown quantity at this point 
Solved Threads: 0
Stivi's Avatar
Stivi Stivi is offline Offline
Light Poster

Re: Replacing "Enter" in textBox

 
0
  #4
Sep 23rd, 2006
Originally Posted by tgreer View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 95
Reputation: ManicCW is an unknown quantity at this point 
Solved Threads: 11
ManicCW's Avatar
ManicCW ManicCW is offline Offline
Junior Poster in Training

Re: Replacing "Enter" in textBox

 
0
  #5
Sep 27th, 2006
Try this:

  1. Me.MyLiteral.Text = Me.MyTextBox.Text.Replace(ControlChars.NewLine, "<br />")
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 49
Reputation: navyjax2 is an unknown quantity at this point 
Solved Threads: 1
navyjax2 navyjax2 is offline Offline
Light Poster

Re: Replacing "Enter" in textBox

 
0
  #6
Nov 10th, 2008
  1. string text = txtBody.Text.Replace(Environment.NewLine, "<br />");
Worked fine for me when putting it into a new MailMessage:

  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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC