Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a gridview which includes a dynamically created hyperlink in one column. The problem is whenever the column contains same text and if i click one link, the other link with same text is alsochanges it's color as clicked.. Why it's happening and is there any solution for this???

Thanks in advance..
Posted

It's happening because your url's aren't unique and your browser changes the color of recently clicked url's.

You could use the row number,for example, as parameter just to make each url unique.

Each url will become something like : www.yoururl.com?rowid=1
 
Share this answer
 
You need to do create a CSS file for your theme in which you can specify it.
The trick is to use a pseudo-class for the a (anchor) selector. Example:
a:visited { color: blue; }


If you place this in your theme CSS file, this will color all visited links in your web blue. Now, I assume you would like to control this a little better to only apply for the links in the GridView for example. To do this, you either set a CSS class for the asp:HyperLink, using the CssClass attribute, or you do the same with the GridView (set the CssClass). Either way, you use the name of the css class in your css rule. This is to scope the rule to only apply in a this specific context. Example:
<asp:HyperLink CssClass="gwlink" runat="server" NavigateUrl="....."></asp:HyperLink>


Then in your CSS file, you do:
.gwlink a:visisted { color: blue; }

This will effectively render all visited links marked as gwlink in blue.
 
Share this answer
 

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