I am useing the code below for a menu but where the item1, item2.. is I would like to have a linkbutton apear when displayed in the bullets. Any code I place in quotes will show the code on the page and not my intended resoults. Please point me in the right direction.
String[] mainmenuitems = { "item1",
"item2",
"item3"};
BulletedList MenuBulletedList1 = new BulletedList();
MenuBulletedList1.Items.Add(mainmenuitems[0]);
MenuBulletedList1.Items.Add(mainmenuitems[1]);
MenuBulletedList1.Items.Add(mainmenuitems[2]);
ContentUpperLeftBlock.Controls.Add(MenuBulletedList1);
ContentUpperLeftSmallTextLabel.Text = "Main menu";
Thanks for any help in advance,
David
Loading

Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 23, 2011, 5:02 PM EDT
string mValue = string.Empty;
for (int i = 0; i < mainmenuitems.GetLength(0); i++)
{
for (int j = 0; j < mainmenuitems.GetLength(1); j++)
{
mText = mainmenuitems[i, j];
mValue = mainmenuitems[i, ++j];
}
ls1 = new ListItem(mText,mValue);
MenuBulletedList1.Items.Add(ls1);
}
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 23, 2011, 3:27 PM EDT
try to create a ListItem and than add the same to the bulleted List, like this (the attribute in bold is important to display the items as hyperlink, you can add this attribute in your code and check the output):
ID="BulletedList1"
runat="server">
Please do not forget to mark "Accepted Answer".
David Rockafellow7 reputationPosted Oct 23, 2011, 3:44 PM EDT
Thank you for the responce. I do have DisplayMode set, where I seem to be stuck on is how to pass the Value="link" and the caption in from behind the scenes. I'm passing in the caption fine but not the value for the link. Did that make more sense?
Thanks again,
David
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 23, 2011, 3:50 PM EDT
BulletedList MenuBulletedList1 = new BulletedList();
MenuBulletedList1.DisplayMode = BulletedListDisplayMode.HyperLink;
ListItem ls1 = null;
foreach (string item in mainmenuitems)
{
ls1 = new ListItem(item,"http://www.microsoft.com/");
MenuBulletedList1.Items.Add(ls1);
}
PlaceHolder1.Controls.Add(MenuBulletedList1);
David Rockafellow7 reputationPosted Oct 23, 2011, 4:17 PM EDT
string[,] mainmenuitems = new string[2, 2] { { "link1", "http://me.com" }, { "link2", "http://me.com" } };
BulletedList MenuBulletedList1 = new BulletedList();
MenuBulletedList1.DisplayMode = BulletedListDisplayMode.HyperLink;
ListItem ls1 = null;
foreach (string item in mainmenuitems)
{
ls1 = new ListItem(item,"XX");
MenuBulletedList1.Items.Add(ls1);
}
ContentUpperLeftBlock.Controls.Add(MenuBulletedList1);
MenuBulletedList1.Visible = true;
ContentUpperLeftSmallTextLabel.Text = "Main menu";
David Rockafellow7 reputationPosted Oct 23, 2011, 5:09 PM EDT