new line character C# for textbox as well as label

Hi All,

how do I show newline breakline in textbox as well as label in C# strictly

for example:

label1.text = "firstSentence<bR>Second sentence" resuls good with new line after "first sentence"

textbox1.text="firstSentence<bR>Second sentence" shows as it is with "<br>" tag in it.

In c# i used System.Environment.Newline

lable1.text="firstSentence" + System.Environment.Newline + "secondsentence" results in

firstsentence secondsentnece.

Textbox1.text="firstSentence" + System.Environment.Newline + "secondsentence" results in

firstsentence

secondsentece......which is good.  But I am saving this message to database.  So server.htmlencode is not helping as it is displaying html tag in the textbox but good in lable.

 

Plzzz help me .... this is bugging me a lot

 

Thank you all

Carol

0
carol123
12/6/2005 2:25:21 PM
📁 asp.net.web-forms
📃 93655 articles.
⭐ 1 followers.

💬 4 Replies
👁️‍🗨️ 1002 Views

Hi Carol,

The best thing I can think of is to store message to DB using any one of methods (say <br>) and execute some processing when using retrieved strings in TextBoxes (replace <br> with Enviroment.NewLine).


Leon Langleyben

MCSD, ASP.NET MVP

Blog
0
llangleyben
12/6/2005 6:07:05 PM

Hi Illangleyben,

Thank you.  I am doing the same but the other way.  As I know a particular word "In respnose to:" will be added before storing to database I am finding that word and replaceing it with "<BR>In reposen to <BR>" so that it gets displayed correctly in label too.  With this I done need to worry about storing tags in DATABASE.

 

Thank you once again for the reply.

Carol

0
carol123
12/6/2005 6:16:47 PM

Hi,

   for the textbox try this

textbox1.text = "firstSentence" + "\r\n" + "Second sentence";


Regards,
Alok
0
alokdash
12/19/2007 4:19:21 AM

Use \r\n instead like

TextBox1.Tex = "A" + "\r\n" + "B";

Bu if you are trying to create newline during retrieving the values the use the Environment.NewLine 


Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
12/19/2007 4:56:15 AM
Reply: