Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I putted this code in master page to display menus in all this pages.
XML
<ul>
           <li><a id="lnkHome" href="Default.aspx">Home</a> </li>
           <li><a id="lnkAboutUs" href="AboutUs.aspx">About Us</a> </li>
           <li><a id="lnkDisclaimer" href="Disclaimer.aspx">Disclaimer</a> </li>
           <li><a id="lnkServices" href="Services.aspx">Services</a> </li>
           <li><a id="lnkContactUs" href="ContactUs.aspx">Contact Us</a> </li>
</ul>

And used css to style this menus like ul li,a:hover, a:visited……
Now how I can add difference appearance in particular <a> link if that page is currently visiting. E.g. If I click the About Us <a> link then it navigate to AboutUs.aspx page and then I want to set background image in that link and background:none in other links.
Posted
Updated 29-Jul-12 3:25am
v2

You can do it by "a:active", but I have not tried :p.
When I was searching in google, I found one post - CSS, menu:active not working[^], where it is stated that "a:active" is not working, but it has an accepted answer.

You can see, the person who has given the answer commented again below the answer about how to achieve it if "a:active" is not working.
So, follow his suggestions.
Hope it helps.
 
Share this answer
 
Use the id. Here is a sample.

in aspx file
ASP.NET
<div id="menuInside">
	<ul id="nav-mini">
		<li><asp:linkbutton id="LinkButton1" runat="server"></asp:linkbutton></li>
		<li><asp:linkbutton id="LinkButton2" runat="server"></asp:linkbutton></li>
		<li><asp:linkbutton id="LinkButton3" runat="server"></asp:linkbutton></li>
		<li><asp:linkbutton id="LinkButton4" runat="server"></asp:linkbutton></li>
		</ul>
</div>


in css file.
CSS
#menuInside a#LinkButton1{
...
}
#menuInside a#LinkButton1:hover{
...
}

#menuInside a#LinkButton2{
...
}
#menuInside a#LinkButton2:hover{
...
}

hope this helps.
 
Share this answer
 
v2
you can try like this
XML
<ul>
           <li><a class="liselected" id="lnkHome" href="Default.aspx">Home</a> </li>
           <li><a id="lnkAboutUs" href="AboutUs.aspx">About Us</a> </li>
           <li><a id="lnkDisclaimer" href="Disclaimer.aspx">Disclaimer</a> </li>
           <li><a id="lnkServices" href="Services.aspx">Services</a> </li>
           <li><a id="lnkContactUs" href="ContactUs.aspx">Contact Us</a> </li>
</ul

>


.liselected
{
background-color:#333;
.......
.......
}
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900