I have records in the database that have bullet points in them. When I retrieve the data with bullet points and display them on a Razor page view, it would appear something like this:
Measures 24”x10”x12” or 2,800 cubic inches of storage space 3 layer laminated polyester waterproof fabric Commercial grade zipper Reinforced steel frame closure Extra heavy duty bottom panel 5 exterior pockets 6 interior pockets Writable name plate
But I want them to display them like this:
Measures 24”x10”x12” or 2,800 cubic inches of storage space
3 layer laminated polyester waterproof fabric
Commercial grade zipper
Reinforced steel frame closure
Extra heavy duty bottom panel
5 exterior pockets
6 interior pockets
Writable name plate
How can I approach this. I'm a little confused on how to tackle this.
Any suggestions?
To give more context, the user can copy and paste into a description box like the one I have screenshotted (see below). Once they save the product it appears to me that it goes into a single string as shown below. I know there are 3 records showing but my question still stands. When the user is copying and pasting it shows the correct format but when retrieving it it shows a single string.
A simple demo you could follow:
View
@model string
@{
var bulletPoints = Model?.Split('', StringSplitOptions.RemoveEmptyEntries);
}
<ul>
@foreach (var point in bulletPoints)
{
<li>@point.Trim()</li>
}
</ul>
Controller
public IActionResult Index()
{
string data = " Measures 24”x10”x12” or 2,800 cubic inches of storage space 3 layer laminated polyester waterproof fabric Commercial grade zipper Reinforced steel frame closure Extra heavy duty bottom panel 5 exterior pockets 6 interior pockets Writable name plate";
return View("Index",data);
}