Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Want to put a Line Break in a MultiLine Text box

Posted on 2004-10-30
12
Medium Priority
?
504 Views
Last Modified: 2012-06-21

<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
0
Comment
Question by:MikeMCSD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
12 Comments
 
LVL 28

Expert Comment

by:mmarinov
ID: 12453516
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
 
LVL 6

Assisted Solution

by:ryerras
ryerras earned 400 total points
ID: 12453526
try to put '\n' for a new line instead of <br>
0
 
LVL 16

Author Comment

by:MikeMCSD
ID: 12459753
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:ryerras
ID: 12459972
what do you want then. I thought you want a line break?
0
 
LVL 6

Expert Comment

by:ryerras
ID: 12460107
Please take a look at what you requested initially ...

Add message here.            - - break line here - -
Click Add when done.
0
 
LVL 16

Author Comment

by:MikeMCSD
ID: 12460511
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
 
LVL 6

Expert Comment

by:ryerras
ID: 12460577
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
 
LVL 28

Expert Comment

by:mmarinov
ID: 12460848
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
 
LVL 16

Author Comment

by:MikeMCSD
ID: 12465178
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
 
LVL 6

Expert Comment

by:ryerras
ID: 12465384
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
 
LVL 28

Accepted Solution

by:
mmarinov earned 600 total points
ID: 12466515
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
 
LVL 16

Author Comment

by:MikeMCSD
ID: 12469040

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question