Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have many links among which I want to highlight the link which is selected in asp.net.I want to show that particular link is selected by diffrent color among many link.

Can you give me any idea to do this?

Thanks in advance
Posted
Updated 8-Sep-10 1:46am
v2

You need to set Hyperlink colors for different states using CSS as follows

CSS
<style type="text/css">
a:link {
COLOR: #0000FF;
}
a:visited {
COLOR: #800080;
}
a:hover {
COLOR: #FF0000;
}
a:active {
COLOR: #00FF00;
}
</style>
 
Share this answer
 
Comments
diptichalke2010 8-Sep-10 7:44am    
Reason for my vote of 3
it's not keeping the constant focus on active link if u click anywhere on the page the color will lost.
With the help of JavaScript, please try this:

Step1:- In my case, there are three HyperLink(a1,a2,a3)in my .aspx page. Suppose, we want to set the color (a1:-Red, a2:- Green, a3:-Blue) on the click of the button (onclick).
XML
<a id="a1" onclick="showred()">Red</a><br />
<a id="a2" onclick="showgreen()">Green</a><br />
<a id="a3" onclick="showblue()">Blue</a>

Step2:- In the head part, we specify the JavaScript function:-
JavaScript
function showred()
{
document.getElementById('a1').style.color='Red';
}
function showgreen()
{
 document.getElementById('a2').style.color='Green';
}
function showblue()
{
 document.getElementById('a3').style.color='Blue';
}
 
Share this answer
 
v2
Comments
Sandeep Mewara 11-Sep-10 13:51pm    
Hi Mahak,

Please use PRE tags to format your code part. It makes the answer more readable.
Further, please avoid using text speak.

You are doing good. :thumbsup:

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