Home » General

LinkButton CssClass Not Working – ASP .NET

10 June 2009 1,633 views No Comment

I have two css classes like this:

.folderTextON,a.folderTextON:active,a.folderTextON:link,a.folderTextON:visited {color:#fff;font:bold 10px/12px Verdana,Arial;text-decoration: none;}
a.folderTextON:hover         { text-decoration: none; color: #FFFFFF; }

.folderTextOFF,a.folderTextOFF:active,a.folderTextOFF:link,a.folderTextOFF:visited {color:#AD9596;font:bold 10px/12px Verdana,Arial;text-decoration: none;}
a.folderTextOFF:hover         { text-decoration: none; color: #fff; }

I also have LinkButton like this:

<asp:linkbutton id=”linkbtn” CssClass=”folderTextOFF” Runat=”server”>A Link Button</asp:linkbutton>

On code behind I tried to set the css class like this:

linkbtn.CssClass=”folderTextOn“;

This does not not work. On any browser at all. The class code and all others are ok.Whats the problem?

Problem is the CssClass I assigned did not have ON all uppercase as I defined on the style. Modifying that this works:

linkbtn.CssClass=”folderTextON“;

Apparently on code behind class name need to be case sensitive. Whereas it does not matter on the asp page.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.