Link in BulletedList from Code

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.
 
M

Mansi Shah

Hi,

You can Add <a> tag to Bulletedlist like,

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



Regards,
Mansi Shah.
 
S

Sunfire

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?
 
J

Jonathan Wood

Wouldn't that make the entire list a link? Is there no way to make list
items links?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top