I have this code in C# code-behind:
for (int i = PIndex2; i < PIndex2 + 10 && i < PCount; i++)
{
NavMenu.Items.Add(new MenuItem
{
Text = (i + 1).ToString(),
NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (i + 1).ToString()
});
if (i == PIndex)
{
MenuItemStyle ms = new MenuItemStyle();
ms.CssClass = "div.navmenu ul li a:focus";
}
}
I want to change the background color if the page is the current page (which I keep in a variable called PIndex). I can't seem to find the proper syntax to do it. I have tried using both a:focus and a:active in my CssClass statement, neither of which worked.
My CSS is as follows:
/* NAV MENU */
div.navmenu
{
padding: 2px 0px 2px 4px;
display: table;
margin: 0 auto;
text-align: center;
}
div.navmenu ul
{
list-style: none;
margin: 0px;
padding: 0px;
width: auto;
color: White;
}
div.navmenu ul li a, div.navmenu ul li a:visited
{
background-color: #465c71;
/* background-color: white; */
border: 1px #4e667d solid;
color: white;
display: block;
line-height: 1.35em;
padding: 4px 20px;
text-decoration: none;
white-space: nowrap;
}
div.navmenu ul li a:hover
{
background-color: white;
color: #465c71;
text-decoration: none;
}
div.navmenu ul li a:active, div.navmenu ul li a:focus,
{
background-color: #cfdbe6 !important;
/* color: #cfdbe6; */
color: White;
text-decoration: none;
}
Hover works fine. However, once I'm on the page I want the item's background color to be what's in a:active.