Created
November 19, 2013 12:16
-
-
Save csharpforevermore/7544504 to your computer and use it in GitHub Desktop.
Output a list of strings as an ordered list of HTML e.g. <ol> <li> ... </li><li>...</li></ol>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static HtmlString OrderedList(IEnumerable<string> items) | |
{ | |
var sb = new StringBuilder(); | |
var orderedList = new TagBuilder("ol"); | |
foreach (var item in items) | |
{ | |
var listItem = new TagBuilder("li"); | |
listItem.SetInnerText(item); | |
sb.AppendLine(listItem.ToString(TagRenderMode.Normal)); | |
} | |
orderedList.InnerHtml = sb.ToString(); | |
return new HtmlString(orderedList.ToString(TagRenderMode.Normal)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment