Hi friends,
i am buliding my menu in the master pager like below in C# and asp.net 2.0 and iam get these menu from database dynamically
private void GenerateMenuItems()
{
ContentManagement.Menu[] menuList = (ContentManagement.Menu[])Session["MenuItems"];
if (menuList != null)
{
Table menuTable = new Table();
menuTable.Width = Unit.Percentage(100);
menuTable.BorderStyle = BorderStyle.None;
menuTable.CellSpacing = 0;
menuTable.CellPadding = 0;
TableRow tablewRow = new TableRow();
foreach (ContentManagement.Menu menu in menuList)
{
TableCell tc = new TableCell();
tc.CssClass = "menu";
HtmlAnchor a = new HtmlAnchor();
a.HRef = "~/Student/" + menu.MenuUrl;
a.InnerHtml = menu.MenuName;
a.Attributes.Add("class", "menu_lnk");
a.Attributes.Add("OnClick", "san");
tc.Controls.Add(a);
tablewRow.Cells.Add(tc);
TableCell tc1 = new TableCell();
tc1.Width = Unit.Pixel(1);
HtmlImage img = new HtmlImage();
img.Src = "../App_Themes/images/menu-sep.gif";
img.Width = 6;
img.Height = 27;
tc1.Controls.Add(img);
tablewRow.Cells.Add(tc1);
}
TableCell tc2 = new TableCell();
tc2.Width = Unit.Percentage(100);
tc2.CssClass = "menu";
tablewRow.Cells.Add(tc2);
menuTable.Rows.Add(tablewRow);
menuPanel.Controls.Add(menuTable);
}
}
now what i want is when some one clicks on any of the links above, i want to change the background color by assigning a css class called selected, so the user will know on what page he/she is on.
any suggestions please.
any ideas how to do it. i appreciate it.