Is there a trimmer function for a razor?

I output the data to the table as follows:

foreach (var attr in item.attr_type) { <td> @foreach (var attrs in attr.attr_value) { @attrs } </td> } 

If there is a cropping function that I can install around @attrs because a lot of free space has been created

+4
source share
2 answers

Not sure what type of attrs there are, but:

 @foreach (var attrs in attr.attr_value) { @(attrs.ToString().Trim())//should work? } 

If this is not the case, you can / must override toString() in your attrs type.

Note: @(..) prints a string in HTML format.

+10
source

Kill formatting

 foreach (var attr in item.attr_type) { <td> @foreach (var attrs in attr.attr_value) { @attrs } </td> } 
0
source

Source: https://habr.com/ru/post/1393147/


All Articles