LINE BREAK ISSUE

Discussion in 'ASP .Net' started by Simon Gare, Mar 17, 2007.

  1. Simon Gare

    Simon Gare Guest

    Hi all,

    have a line of code in a ViewLocation.aspx.cs file below

    StringBuilder sb = new StringBuilder();
    sb.Append("Driver No:
    ").Append(driver.DriverNo.ToString()).Append("<br>");
    sb.Append("Name: ").Append(driver.FirstName).Append("
    ").Append(driver.LastName).Append("<br>");
    sb.Append("Phone: ").Append(driver.PDAPhoneNumber);

    Problem is when it is displayed on the page it shows like this

    Driver No: 1<br>Name: Donald Stewart<br>Phone etc etc

    Should be

    Driver No: 1
    Name: Donald Stewart
    Phone: 07912 000000 etc etc

    Anyone help?

    Regards
    Simon


    --
    Simon Gare
    The Gare Group Limited

    website: www.thegaregroup.co.uk
    website: www.privatehiresolutions.co.uk
    Simon Gare, Mar 17, 2007
    #1
    1. Advertising

  2. Simon Gare wrote:
    > Hi all,
    >
    > have a line of code in a ViewLocation.aspx.cs file below
    >
    > StringBuilder sb = new StringBuilder();
    > sb.Append("Driver No:
    > ").Append(driver.DriverNo.ToString()).Append("<br>");
    > sb.Append("Name: ").Append(driver.FirstName).Append("
    > ").Append(driver.LastName).Append("<br>");
    > sb.Append("Phone: ").Append(driver.PDAPhoneNumber);
    >
    > Problem is when it is displayed on the page it shows like this
    >
    > Driver No: 1<br>Name: Donald Stewart<br>Phone etc etc
    >
    > Should be
    >
    > Driver No: 1
    > Name: Donald Stewart
    > Phone: 07912 000000 etc etc
    >
    > Anyone help?


    The problem is not in the code that you have shown, but in the code that
    you haven't shown. The StringBuilder doesn't show anything on the page,
    it only creates a string. It's the way that you display the string on
    the page that decides how it's going to show up.

    You are using a method that html encodes the string when it's shown on
    the page. What you want to do is to use a method that doesn't.

    --
    Göran Andersson
    _____
    http://www.guffa.com
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Mar 17, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hugo
    Replies:
    10
    Views:
    1,299
    Matt Humphrey
    Oct 18, 2004
  2. kaushikshome
    Replies:
    4
    Views:
    759
    kaushikshome
    Sep 10, 2006
  3. Replies:
    12
    Views:
    954
  4. scad
    Replies:
    23
    Views:
    1,155
    Alf P. Steinbach
    May 17, 2009
  5. Sumantra

    Unnecessary Line Break Issue

    Sumantra, Aug 24, 2006, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    682
    Sumantra
    Aug 24, 2006
Loading...

Share This Page