How to set a:visited and a:hover programmatically in ASP.NET


Tags: c#,asp.net,css,hover

Problem :

Can someone tell me how to set a:visited and a:hover programmatically? I am dynamically building up some hyperlinks server-side and want to know how to specify unique css behaviour for each link. Otherwise I would set them all in a stylesheet.



Solution :

If you want to set the style for a single item, you can use the CssClass attribute, then set up the classes in your css.

.linkA:visited {
    color: red;
}
.linkB:visited {
    color: blue;
}

In your codebehind:

LinkOne.CssClass = "linkA";
LinkTwo.CssClass = "linkB";

    CSS Howto..

    How to avoid text selection in web page using css?

    How do I fit a fieldset to the size of its content with CSS?

    How to send an HTML file with css?

    How to emulate Google greyed-out suggested text in input element?

    How to get CSS table-cell to 100% for responsive design [closed]

    How to prevent mobile keyboard from rising footer over the text fields?

    How to change URL inside CSS?

    How to hide Firefox context menu to show my own menu instead?

    how to use .css to add an address to the end of every .html page?

    How to create shape image border with clickable container?(use HTML and CSS)

    CSS: how to position buttons in groups across a row on a web page

    How can I erase a border piece using CSS?

    How can I use jQuery and/or CSS3 to change how many unordered list items are displayed?

    How is the “greater than” or “>” character used in CSS?

    How to get rid of !important tags?

    how to change style of a css element using jQuery

    IE11 CSS bug with clear:right - how to workaround?

    How to add CSS class to asp.net from code behind [closed]

    Show some characters above a picture on hover

    How to make a fixed position centered after zooming the whole website out?

    How to Add a Vertical Line inside a texbox using html and css

    How do I get JavaScript to clear the previous onclick element when a user moves on to the next click?

    How to keep line breaks when using .text() method for jQuery?

    How to replicate PS multiply layer mode

    How can I tell if a particular CSS property is inherited with jQuery?

    How to have different layout orders for same html code for desktop and desktop using css or javascript (not jquery)

    How to replace @media (max-width) using Stylish or Greasemonkey?

    how to create arrow between two background images in css

    How to include CSS in laravel 5 running with artisan?

    How can I display an image as a menu item once the user has scrolled down the page 150px?