473,396 Members | 2,004 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,396 software developers and data experts.

How to get UserName of logon control from code

I have added a Login control to a Master Page. the control shows the
currently logged in user (domainname\username).
In one of the content pages, I need to access this name.
I noticed that the Login control has a UserName property but it's in
the Nonpublic properties, so it's not accessible from my code.

I was trying to get to the name as follows:
string username = ((LoginName)
Master.FindControl("lnLoginName")).UserName;

but that's failing...

I was thinking of adding the username to a session variable, but I
have a feeling that it's not the right approach in today's new world
of web programming.

Does anyone know how to get the current username in a code-behind file
for a content page? Or is there something fundamental that I'm
missing?

Thanks in advance.

-- Hans

Jul 11 '07 #1
1 1708
There's a useful article on this issue here:
http://west-wind.com/weblog/posts/5127.aspx

Regards,

Tim.
Jul 11 '07 #2

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

Similar topics

14
by: John Davis | last post by:
Anyone knows how to create the username/password authorization dialog in ASP? Thanks, John
2
by: TIML | last post by:
I have tried using servervariables("XXX") to request the username and computer name of the individual running code on our internal server, but what I want and can't seem to capture is the user's...
1
by: ChrisB4745 | last post by:
I'm working on a system service application that is supposed to report various information about the computer it is running on back to a central server. One of the things I need to know is the...
8
by: Jonathan Dixon | last post by:
I am developing an intranet and was wondering, when a user logs on is there a way to get the username of the windows account in asp.net. I have tried the following but they return the worker...
8
by: Raj Thakkar | last post by:
Hi, I am currenty working on a site for intranet. I have a user control in the header of every page that will be displayed only if people with certain username are surfing the site. These lists...
1
by: Keith Patrick | last post by:
Currently, if I declare an asp:Login control on a page and login, on both OnAuthenticate and OnLoggedIn, this.Profile.UserName is still null, even though the user does get authenticated and shows...
12
by: Cecil | last post by:
Does this make sense for a logon table: CREATE TABLE Logon ( ID INT NOT NULL IDENTITY PRIMARY KEY, name VARCHAR(15) NOT NULL, password VARCHAR(15) NOT NULL ) GO CREATE UNIQUE INDEX...
6
by: tsmojver | last post by:
Does anyone know how to retreive the logon account username for a particular windows service? Or the current user that is running this service as a process. C# is the prefered language of choice. ...
1
vikas251074
by: vikas251074 | last post by:
I easily connected to oracle table using this password and username in TOAD software. I am using following way to connect to oracle table, but I am getting error 'ORA-01004: default username feature...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.