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.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
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();
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
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
40 Points
121 Posts
convert lines of text to <ul>
Jan 10, 2018 01:50 PM|Bradly|LINK
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
Contributor
2930 Points
1210 Posts
Re: convert lines of text to <ul>
Jan 11, 2018 01:20 AM|Deepak Panchal|LINK
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
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
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
All-Star
50641 Points
9835 Posts
Re: convert lines of text to <ul>
Jan 11, 2018 01:32 AM|A2H|LINK
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.
Code to create UnOrderedList
Aje
My Blog | Dotnet Funda
Member
40 Points
121 Posts
Re: convert lines of text to <ul>
Jan 11, 2018 07:06 AM|Bradly|LINK
@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
Contributor
2930 Points
1210 Posts
Re: convert lines of text to <ul>
Jan 12, 2018 09:23 AM|Deepak Panchal|LINK
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
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.