views:

16

answers:

1

If I use this code on my aspx page:

<asp:BulletedList ID="listClientContacts" runat="server">
    <asp:ListItem><b>My Name</b></asp:ListItem>
 </asp:BulletedList>

The text renders as literal <b>My Name</b> instead of making the text bold. The same thing happens if I try to add a list item from the VB side of things:

 Dim li As ListItem = New ListItem("<b>My Name</b>")
 Me.listClientContacts.Items.Add(li)

Is there a way to add HTML to a ListItem in ASP, or is there a better way to dynamically generate a list?

+1  A: 

Is your list from a data-source? If so, then just use a repeater

<ul>
    <asp:Repeater runat="server" DataSourceID="sqlDataSource1">
        <ItemTemplate>
            <li><b><asp:Literal runat="server" Text=<%#Eval("Field") %>></asp:Literal></b></li>
        </ItemTemplate>
    </asp:Repeater>
</ul>
Hugh Jeffner