Answered by:
convert lines of text to <ul>

Question
-
User-1232255770 posted
Is there an easy method to convert lines if text to an ordered / unorderd list ?
line1
line2
line2
<ul>
<li>line1</li>
<li>line2</li>
<li>line3</li>
</ul>Thanks
Wednesday, January 10, 2018 1:50 PM
Answers
-
User347430248 posted
Hi Bradly,
generally you need to create Ordered / Unordered list in code, but you had asked for the other way.
below is the way you can try.
Create a bulleted or numbered list
Tip:
You can set many other properties for a list, such as margins and text properties, by applying a style to the list or a particular list item. For more information, see Create a style.
To create a bulleted or numbered list
-
In Design view or Code view, in your web page, place your cursor where you want to create a list, and then do one of the following:
-
To create a regular bulleted list, either, on the Common or Formatting toolbar, click the Bullets button
, or on the Formatting toolbar, click the Style box, and select Unordered List <ul>.
-
To create a regular numbered list, either, on the Common or Formatting toolbar, click the Numbering button
, or on the Formatting toolbar, click the Style box, and select Ordered List <ol>.
-
To create a list that uses a picture to mark each list item, on the Format menu, click Bullets and Numbering. In the List Properties dialog box, click the Picture Bullets tab. Under Picture, either select Use current CSS Style to use the image specified by a CSS Style or select Specify picture to choose a picture. If you selected Specify picture, click Browse and select a picture and click Open, and then click OK.
-
To create a custom bulleted list, on the Format menu, click Bullets and Numbering. In the List Properties dialog box, click the Plain Bullets tab, click a bullet style, and click OK.
-
To create a custom numbered list, on the Format menu, click Bullets and Numbering. In the List Properties dialog box, click the Numbers tab, and click a number style. To set the starting number, under Start at:, type a number, and click OK.
-
-
For each item or line of text that you want in the list, type the text, and then press ENTER to add a bullet or number to the list.
-
When you have typed the last item, press ENTER twice to end the list.
Reference:
Create a bulleted or numbered list
Regards
Deepak
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, January 11, 2018 1:20 AM -
-
User347430248 posted
Hi Bradly,
that approach will only work if there is a designer window.
in MVC, CSHTML file there is no any designer is available so because of this reason above approach will not work for you.
in that case, you have to use code to add OL / UL.
Thanks for your understanding.
Regards
Deepak
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, January 12, 2018 9:23 AM
All replies
-
User347430248 posted
Hi Bradly,
generally you need to create Ordered / Unordered list in code, but you had asked for the other way.
below is the way you can try.
Create a bulleted or numbered list
Tip:
You can set many other properties for a list, such as margins and text properties, by applying a style to the list or a particular list item. For more information, see Create a style.
To create a bulleted or numbered list
-
In Design view or Code view, in your web page, place your cursor where you want to create a list, and then do one of the following:
-
To create a regular bulleted list, either, on the Common or Formatting toolbar, click the Bullets button
, or on the Formatting toolbar, click the Style box, and select Unordered List <ul>.
-
To create a regular numbered list, either, on the Common or Formatting toolbar, click the Numbering button
, or on the Formatting toolbar, click the Style box, and select Ordered List <ol>.
-
To create a list that uses a picture to mark each list item, on the Format menu, click Bullets and Numbering. In the List Properties dialog box, click the Picture Bullets tab. Under Picture, either select Use current CSS Style to use the image specified by a CSS Style or select Specify picture to choose a picture. If you selected Specify picture, click Browse and select a picture and click Open, and then click OK.
-
To create a custom bulleted list, on the Format menu, click Bullets and Numbering. In the List Properties dialog box, click the Plain Bullets tab, click a bullet style, and click OK.
-
To create a custom numbered list, on the Format menu, click Bullets and Numbering. In the List Properties dialog box, click the Numbers tab, and click a number style. To set the starting number, under Start at:, type a number, and click OK.
-
-
For each item or line of text that you want in the list, type the text, and then press ENTER to add a bullet or number to the list.
-
When you have typed the last item, press ENTER twice to end the list.
Reference:
Create a bulleted or numbered list
Regards
Deepak
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, January 11, 2018 1:20 AM -
-
User2103319870 posted
You can use StringBuilder to create UnOrderedList from records in List
Sample Implementation
HTML
Div to hold the UnOrderedList. Make sure you have added runat="server" so that div will be accessible in code behind.
<div id="unOrderedlistDiv" runat="server"> </div>
Code to create UnOrderedList
string line; // Read the file System.IO.StreamReader file = new System.IO.StreamReader(@"D:\Forums\files\samplefile.txt"); StringBuilder sb = new StringBuilder(); //Create the UnOrderedList sb.Append("<ul>"); //Loop through each records while ((line = file.ReadLine()) != null) { //Add the value to list sb.Append("<li>" + line + "</li>"); } //Add the ending tag sb.Append("</ul>"); //Assign it to div unOrderedlistDiv.InnerHtml = sb.ToString(); file.Close();
Thursday, January 11, 2018 1:32 AM -
User-1232255770 posted
@Deepak
Thanks for your answer , i am using asp.net mvc , in my cshtml file the toolbar is not displayed. its turned on when i look at the settings.
Sometimes i use standard html for parts of a website . Would be nice to do this quicker
Thursday, January 11, 2018 7:06 AM -
User347430248 posted
Hi Bradly,
that approach will only work if there is a designer window.
in MVC, CSHTML file there is no any designer is available so because of this reason above approach will not work for you.
in that case, you have to use code to add OL / UL.
Thanks for your understanding.
Regards
Deepak
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, January 12, 2018 9:23 AM