473,405 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

how to create this class?

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 with the code here below (without class) but this works only
for the (redirected) 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

Mar 4 '07 #1
1 1096
The solution is: page.User.Identity.IsAuthenticated

"Chris" <??**@nospam.dcschreef in bericht
news:OJ**************@TK2MSFTNGP02.phx.gbl...
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 with the code here below (without class) but this works only
for the (redirected) 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

Mar 4 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: jon wayne | last post by:
OK! I had this nagging doubt Consider (without worrying abt access specifiers) class Kid : public Parent{...}; Parent::someFunc() { Kid k; }
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
2
by: Migrant | last post by:
Hi Friends; I want develop a group logic with C# (n tier refraction).I know I must create a Class and inherit it But I don't have enough know-how about develop classes. Somebody can help me? ...
4
by: Joe HM | last post by:
Hello - I have a Base Class where I want a New() implemented that can be called from the outside. This New() should create an instance of the appropriate cDerivedX Class ... The following...
7
by: MarkoH | last post by:
Wsdl.exe /server creates abstract class derived from WebService. Is there a way to create this class at runtime based on some WSDL file given at runtime ? What would be even better - creating...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
24
by: M O J O | last post by:
Hi, Instead of doing this.... Public Class Form1 Public Shared Sub CreateAndShow() Dim f As New Form1 f.Show() End Sub
2
by: Angel Of Death | last post by:
I have a method. It takes some XML as a parameter. Depending on the content of the XML it should create a specific object and call a KNOWN method. So: public void PersistXml(string XmlData){} ...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.