problem with class creation

Le
Chris
Hi,

i need to check on every page whether a user is logged or not. If yes, the
theme must be changed.

I first tried like this but this works only for the default.aspx file (the
code-behind can't be put in masterpage.master.vb because
'User.Identity.IsAuthenticated ' is not recognized!).

in masterpage.master:
<header>
<link id="Lkred" href="App_Themes/red/red.css" rel="Stylesheet"
type="text/css" visible="true"/>
<link id="lkgreen" href="App_Themes/green/green.css" rel="Stylesheet"
type="text/css" visible="false" />
</header>
in default.aspx.vb:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
If User.Identity.IsAuthenticated Then
If Master.FindControl("lkred").Visible = True Then
Master.FindControl("lkred").Visible = False
Master.FindControl("lkgreen").Visible = True
Else
Master.FindControl("lkred").Visible = True
Master.FindControl("lkgreen").Visible = False
End If
End If
End Sub

So i would like to create a Class in order to put the code on a central
place instead to have to copy it in every page. But the problem is now: how
to define 'User.Identity.IsAuthenticated'? I can't find a type 'user' or
something..

Any help would be appreciated.

Thanks

Chris

Public Class loginkl
Public Sub logkl()

dim us as ??
End Sub
End Class
Vidéos High-Tech et Jeu Vidéo
Téléchargements
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
Chris
Le #12263011
page.User.Identity.IsAuthenticated

"Chris" news:%
Hi,

i need to check on every page whether a user is logged or not. If yes, the
theme must be changed.

I first tried like this but this works only for the default.aspx file (the
code-behind can't be put in masterpage.master.vb because
'User.Identity.IsAuthenticated ' is not recognized!).

in masterpage.master:
<header>
<link id="Lkred" href="App_Themes/red/red.css" rel="Stylesheet"
type="text/css" visible="true"/>
<link id="lkgreen" href="App_Themes/green/green.css" rel="Stylesheet"
type="text/css" visible="false" />
</header>
in default.aspx.vb:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If User.Identity.IsAuthenticated Then
If Master.FindControl("lkred").Visible = True Then
Master.FindControl("lkred").Visible = False
Master.FindControl("lkgreen").Visible = True
Else
Master.FindControl("lkred").Visible = True
Master.FindControl("lkgreen").Visible = False
End If
End If
End Sub

So i would like to create a Class in order to put the code on a central
place instead to have to copy it in every page. But the problem is now:
how to define 'User.Identity.IsAuthenticated'? I can't find a type 'user'
or something..

Any help would be appreciated.

Thanks

Chris

Public Class loginkl
Public Sub logkl()

dim us as ??
End Sub
End Class





Publicité
Poster une réponse
Anonyme