Posts

Showing posts from June, 2009

How to Get the ASP.NET LinkButton CssClass Property to Work

Hopefully this will save someone a lot of time. Today I was working on a webpage in ASP.NET and made use of the LinkButton control. But when I applied a CSS class using the CssClass property, it just wouldn't take. After much searching, I found the solution. First off, this is a bug -- you can't spin it any other way. Fortunately, there IS a way to get it to work: you need to specify one of the following qualifiers on your CSS class: visited, link, or active . For example, when I tried to apply the following class, it wasn't reflected in the control: .Pager { font-family:Verdana; font-size:8pt; font-weight:bold; color:Orange; } However, when I added the link qualifier (":link" added to the class name), it worked like a charm: .Pager:link { font-family:Verdana; font-size:8pt; font-weight:bold; color:Orange; } When you apply the class name to the CssClass property of the control, leave out the qualifier . For example, using my class above, I set the valu