This project is read-only.

CSS style, changing login/logoff link

Topics: Themes
Sep 23, 2009 at 2:54 PM

Hi there,

I moved the link for the login/logoff to the header of my page, but I can't make it work like this:

1. If the user is not logged in, display only the text "Log in"
2. if the user is logged in, display the text "Log off" and a little "X" to the right of it.

This is my code at the header on the site.master of my theme (I created a new folder, say, "mytheme"):

<div id="header">
<span class="txt-login"><a runat="server" id="aLogin" /></span>

and this is my CSS, also located at "mytheme" folder:

#header span.txt-login a { display:block; }
#header span.txt-login a[href^="\/login.aspx?logoff"] { color:white !important; background:url(img/btn_sair.jpg) no-repeat right middle; padding-right:20px; }

I quite dont understand how to use that a[href..] on the CSS. What am I doing wrong here? Its not applying the background when I'm logged in.


Sep 23, 2009 at 4:34 PM

It might be easier to use something like:

<% if(Page.User.Identity.IsAuthenticated){ %>
   <span>log off</span>
<% } else { %>
   <span>log in</span>
<% } %>

Sep 23, 2009 at 10:18 PM

It worked! I just had to make some changes to my CSS. Thank you.