简体   繁体   中英

C# MVC - How to display records from SQL with intended line breaks

I am developing a new application in C# MVC and have ran into an issue when displaying data from my table onto the webpage. I can successfully display the data from my table onto a webpage with no errors however one of my columns in my table can have multiple pieces of information. For Example;

Column Example Data = "Information 1; information 2; information 3;"

This successfully displays to a html table in my view however I would like to take a new line after each ";" . I have tried to wrap this in HTML and store it in my SQL but this still doesn't work. Instead the tag is just printed as text on the page.

If anyone would know how to go about this, it would be appreciated.

I think before rendering that date you should use yourcontent.replace(";", Environment.NewLine);

and return new IHTMLString(yourcontent) or use HTML.Raw(yourcontent)

This is pseudo code, just so you get the idea.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM