ASP.NET 2.0 BulletedList Control


ASP.NET 2.0 BulletedList control is used to create a list of items formatted with bullets such as circular and rectangle bullets. This tutorial shows how to use BulletedList control.

The following code creates a BulletedList with quare bullet.

<asp:BulletedList ID=BulletedList1 BulletStyle=Square runat=server>
<asp:ListItem>C# Corner</asp:ListItem
>
<asp:ListItem>VB.NET Heaven</asp:ListItem
>
<asp:ListItem>Longhorn Corner</asp:ListItem
>
<asp:ListItem>.NET Heaven</asp:ListItem
>
</asp:BulletedList>

The BulletStyle attribute represented by the BulleteStyle enumeration of BulletedList decides the type of the bullet. Figure 1 shows the BulleteStyle enumeration.

Figure 1. BulletStyle enumeration

Another important attribute of BulletedList is DisplayMode, which represents the display mode of the bulleted list. The DisplayMode is of type BulletedListDisplayMode enumeration listed in Figure 2. For example, if you want to create a bulleted list with hyperlinks, you need to set the DisplayMode to HyperLink.

Figure 2. BulletedListDisplayMode enumeration

The following code creates a bulleted list with hyperlinks.

<asp:BulletedList ID=BulletedList1 DisplayMode=HyperLink BulletStyle=Square runat=server>
<asp:ListItem Value="www.c-sharpcorner.com">C# Corner</asp:ListItem
>
<asp:ListItem Value="www.vbdotnetheaven.com">VB.NET Heaven</asp:ListItem
>
<asp:ListItem Value="www.longhorncorner.com">Longhorn Corner</asp:ListItem
>
<asp:ListItem Value="www.dotnetheaven.com">.NET Heaven</asp:ListItem
>
</asp:BulletedList>

The output looks like Figure 3. If you click on these links, it will launch the web sites.

Figure 3. Hyperlinked Bulleted List

If you use Visual Studio 2005, you can do every thing using the designer.  Simply drop a BulletedList from Toolbox to a page and click the Edit Items list, which launches ListItem Collection Editor. As you can see from Figure 4, I can add the Text and Value of the items.

Figure 4. Adding items to a BulletedList using Visual Studio 2005 Designer


Similar Articles
Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.