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

.



Relevant Pages

  • Re: How to implement a automatic login function
    ... Have you got any progress or idea on this issue or does the suggesetion in ... our previous message help some? ... Ideally all this can be done so that the username and password is not ... How can a post request be fed to whatever class the login control ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to get UserName of logon control from code
    ... I noticed that the Login control has a UserName property but it's in ... Does anyone know how to get the current username in a code-behind file ...
    (microsoft.public.dotnet.framework.aspnet)
  • Login in control without UserName taxt box
    ... I am implementing a login page using ASP.NET 2.0 Login control. ... Authenticate even handler, but I get a "LayoutTemplate does not ... contain an IEditableTextControl with ID UserName for the username." ... Error during page load because I useed Email as the ID of the textbox ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: 2 questions please
    ... The login control is in the anonymous template and a staus view is in ... quest 1. ... How can I set focus to the UserName textbox of the LogIn ...
    (microsoft.public.dotnet.framework.aspnet)
  • Custom Membership Provider with our own SQL Server 2005 table
    ... have the Login control check the username and password against our table, ... functionality, or the new user wizard functionality, and probably not the ... instead of writing a complete custom membership provider from scratch? ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)

Loading