LINE BREAK ISSUE

  • Thread starter Thread starter Simon Gare
  • Start date Start date
S

Simon Gare

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 said:
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.
 
Back
Top