Link in BulletedList from Code

  • Thread starter Thread starter Jonathan Wood
  • Start date Start date
J

Jonathan Wood

I have a master page that contains a BulletedList.

<asp:BulletedList runat="server" id="mainmenu" CssClass="nav">
</asp:BulletedList>

In my page's Load event, I'm populating the bulleted list based on the role
of the current user. Right now, my test code looks like this:

for (int i = 0; i < 8; i++)
{
ListItem item = new ListItem();
item.Text = String.Format("Menu Item {0}", i + 1);
mainmenu.Items.Add(item);
}

The problem is I want to insert an <a> tag so that each list item is a link.

Does anyone know how to dynmically add items to a BulletedList that include
HTML markup?

Thanks.
 
Hi,

You can Add <a> tag to Bulletedlist like,

<a>
<asp:BulletedList runat="server" id="mainmenu" CssClass="nav">
</asp:BulletedList></a>



Regards,
Mansi Shah.
 
Hi... I was wondering the same thing. Except my problem is only a certain
part of list item 7 needs to be a link... how do you do that as well?
 
Wouldn't that make the entire list a link? Is there no way to make list
items links?
 
Back
Top