problem with changing color when logged

B

Bjorn

Hi,.

i try to change the color of the main menu when the visitor of the site is
logged.
When not logged, it must be red, when logged, it must be green.
I start in the Master¨Page with putting the link to the red CSS file to
Visible and to the green CSS file to False..
In code-behind, i test if the loginview has changed: if yes, i change
Visible to False and inverse .
But it always remains red!
See my code:

Thanks for help
Bjorn

aspx file:
-------
<head runat="server">
<link id="lk1" href="Corered.css" rel="stylesheet" type="text/css"
visible="true" />
<link id="lk2" href="Coregreen.css" rel="stylesheet" type="text/css"
visible="false" />
</head>
<body>
<form id="form1" runat="server">
<div id="Menu"> <mai:Mainmenu ID="MMenu1" runat="server" /> </div>
<div id="Content">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder> </div>
</div>
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
</AnonymousTemplate>
<LoggedInTemplate>
</LoggedInTemplate>
</asp:LoginView>

code-behind:
-------------
Protected Sub LoginView1_ViewChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles LoginView1.ViewChanged
If lk1.Visible = "true" Then
lk1.Visible = "false"
lk2.Visible = "true"
Else
lk2.Visible = "false"
lk1.Visible = "true"
End If
End Sub
 
B

bruce barker

unless you put a runat=server on the links, the visible tag is
meaningless for a link

-- bruce (sqlwork.com)
 
B

Bjorn

Thanks for replying...
I added on both link runat="server" like you suggested:
<link id="lk1" href="Corered.css" rel="stylesheet" type="text/css
runat="server" visible="true" />
but it still doesn't work.

Wthout that runat="server", if the visible tag would be then meaningless,
then it would be green, not red, because the green-link comes after the
red-link. Am i wrong?

I thing the problem is elsewhere, but where ...
 
C

Chris Dunaway

Thanks for replying...
I added on both link runat="server" like you suggested:
<link id="lk1" href="Corered.css" rel="stylesheet" type="text/css
runat="server" visible="true" />
but it still doesn't work.

Wthout that runat="server", if the visible tag would be then meaningless,
then it would be green, not red, because the green-link comes after the
red-link. Am i wrong?

I thing the problem is elsewhere, but where ...

Try putting your .css in the App_Themes folder of your application and
then in the Page_Load, set the Page.Theme to the appropriate value.

I'm not certain this will work, but was recently reading the docs on
the Page.Theme property.

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top