Solved

Want to put a Line Break in a MultiLine Text box

Posted on 2004-10-30
501 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
Question by:MikeMCSD
    12 Comments
     
    LVL 28

    Expert Comment

    by:mmarinov
    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
    try to put '\n' for a new line instead of <br>
    0
     
    LVL 16

    Author Comment

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

    Expert Comment

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

    Expert Comment

    by:ryerras
    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
    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
    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
    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
    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
    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:
    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

    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    933 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now