Want to put a Line Break in a MultiLine Text box


<asp:TextBox ID="txtEng" TextMode=MultiLine Visible=False Rows=3 Width=245
Text ="Add message here. Click Add when done."  Runat=server></asp:TextBox>

I want the text in the box to read:
Add message here.            - - break line here - -
Click Add when done.


this doesn't work:
"Add message here.<br> Click Add when done."

Is this possible?
thanks
LVL 16
MikeMCSDAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mmarinovCommented:
Hi MikeMCSD,

in the code behind write

txtEng.Text="Add message here. \rClick Add when done"

i've tried direct in the html designer to that but when you rendering the control the text is encoded and you see the \r as a part of the string

Regards!
B..M
0
ryerrasCommented:
try to put '\n' for a new line instead of <br>
0
MikeMCSDAuthor Commented:
Thanks B..M, ryerras,

I tried both ideas but they didn't work.

I did this and it breaks the line, but I don't know if it's the best solution:

"Add message here.          Click Add when done."
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

ryerrasCommented:
what do you want then. I thought you want a line break?
0
ryerrasCommented:
Please take a look at what you requested initially ...

Add message here.            - - break line here - -
Click Add when done.
0
MikeMCSDAuthor Commented:
ryerras . . what I meant was that by putting the spaces in
the string, it created a line break by "pushing" the next word to the next line:

"Add message here.          Click Add when done."
0
ryerrasCommented:
Hmm. your question is very unclear. Ok, if you want to put space in between certain words, you simplay add whitespace, if you are just assigning a string manually, like this
Text ="Add message here.           Click Add when done."

or Text ="Add message here." + "     " + " Click Add when done."

or insert a tab character to get one tab length of whitespace by inserting \t
.. Let us know what you are trying and what the result you are getting, so we will try to resolve your problem
0
mmarinovCommented:
MikeMCSD, as i told you if you put any character for new line in the HTML it will be encoded and output as text
so you have to add "\r" within your string in the code behind - then the "\r" will not be encoded you will see the new line - i've tested it on my PC and it is woking excelent

Regards!
B..M
0
MikeMCSDAuthor Commented:
B..M,
I tried this in the code behind:
txtEng.Text="Add message here. \rClick Add when done"

and it displays: Add message here. \rClick Add when done   - in the browser.


ryerras  . . my orginal question is clear .  .
when I put those spaces between the words, I was experimenting
and it created a "fake" line break.

0
ryerrasCommented:
Yeah Mike, I understand it. But what do you want to achieve now. Create space between the words or send the words to the next line?
0
mmarinovCommented:
have you tried that
ta.Text = "Add message here. " + Environment.NewLine  + "Click Add when done"

i think the problem with \r is that i've tested in c#, not vb

HTH
B..M
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MikeMCSDAuthor Commented:

Yes,  Environment.NewLine  works . . .

I was trying to think of the break line word I used back in VB4 and found it! :  vbCrLf

This worked also:

txtEng.Text = "Add message here. " & vbCrLf &  + "Click Add when done"

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.