You must Sign In to post a response.
  • Category: ASP.NET

    How to Add New Line in Asp.net C#

    How to enter a new line in asp.net c#. I have tried Environment.newline it is not working, and i also tried system.environment.newline. still they are not working

    suppose i want to print code like this - :
    Hello
    Friends

    thanks in advance
    CP
  • #616796
    I solved it. I used the line break <br/> tag in the Response.Write method as follows.

    Response.Write("Hello<br/>World");


    And got the output as

    Hello
    World

    You too can test it.

    Regards,
    Sibtain Masih
    "Man is still the most extraordinary computer of all."

  • #616798
    Hi i do not know how the Environment.NewLine did not work for you.
    Here is how i use it priorly and it works for me......


    <asp:Label ID="lbladdedcom" ForeColor="Black" Font-Size="Small" Width="710px" Text='<%# Eval("CommentText").ToString().Replace(Environment.NewLine,"<br />") %>'
    runat="server" BackColor="#CCFFCC" BorderColor="#CCFFCC" BorderStyle="Solid"
    BorderWidth="12px"></asp:Label>

    Regards
    Pankaj Rajput

  • #616799
    Hi,

    Try the following :



    Label1.Text = "Hello" + "<br/>" + "Friends";


    Cheers!!!!

    Rajesh Kumar Parbat
    (Mentor,Editor,MVM)

  • #616803
    k thanx, its working

  • #616811
    Hi,

    Response.WriteLine("Hello" + "<br/> + "World");


    Output:-

    Hello
    World


    Thanks & Regards


    Bunty

  • #616836
    Hi Chandra Prakash,
    I hope its working now. Still posting my answer as I am just thinking that there is another way left!!

    I tried by using '\n' and it worked.
    So you could try in this way
    document.write("Hello \n world");

    And it will show the text in 2 lines.

    Thanks
    Pritom Nandy

  • #616869
    you can use </br> or \n


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.