Reputation: 979
This code ASPX file:
Relates to:
<div ID="relatedMeasures" runat="server"></div>
<br />
Code behind loops through items and appends to a string...
foreach (int id in mcsMeasuresSelected)
{
if (mcs.Id == id)
{
// Add to selected
mcsSelectedMeasures.Add(mcs);
output += mcs.Measure + Environment.NewLine;
}
}
relatedMeasures.InnerText = output;
Then the output HTML has no line breaks.
Relates to:
<div id="MainContent_extScope1_relatedMeasures">CPS: Gas Boiler Solid Fuel Boiler Electric Storage Heater </div>
I have also attempted using a span tag instead of div tag and an asp label and also adding "< br / >" or "<br/>" instead of Environment.NewLine
Upvotes: 0
Views: 1951
Reputation: 7462
Use <br/>
instead of Environment.NewLine. Like this.
output += mcs.Measure + "<br />";
and use InnerHTML , like following.
relatedMeasures.InnerHtml = output;
This is the difference between them - Difference between InnerHTML and InnerText property of ASP.Net controls?
Upvotes: 2