.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

How to get username in Login control LoggedIn event?

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :ASP.Net
  I want to keep a log of when people log into the database.  In the LoggedIn event of the Login control, User.Identity.Name is null.  How can I get the username that just logged in?  And how can I track when someone logs out using the login control?  Thanks!

View Complete Post

More Related Resource Links

Login Control LoggedIn Event and Cookies


I don't want to use asp.net default authentication cookie for the "Remember Me" checkbox.  Instead, I only want the cookie to hold the user name and not the password (so the user will have to type their password every time they visit the site.)  The cookie is being created successfully in the login control's LoggedIn event, but if I uncheck the "Remember Me" checkbox and log in, the cookie is never removed.  Here is my LoggedIn code:

Protected Sub log_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles log.LoggedIn
        Dim _userName As String = log.UserName.ToString()
        Dim _rem As CheckBox = CType(log.FindControl("chkRem"), CheckBox) 'Remember Me checkbox
        If _rem.Checked Then
            Response.Cookies("MMuser").Value = _userName
            Response.Cookies("MMuser").Expires = DateTime.Now.AddDays(30)
        ElseIf Not _rem.Checked AndAlso Not IsNothing(Request.Cookies("MMuser")) Then

getting more data for a username from the login control

i have went with the standard membership method for validating and logging users into the application.  i have added a column to the adpnet_Users table called customer_number.once the user is logged in, i want to get the customer number for that user.  what is the best / easiest / industry standard method of accomplishing this?

retrieve username from login control to pass it on as a parameter for poplulation of dropdown box.


Hi guys,

Would appreciate some help with this.

after a successful login I'd like to retrieve the users' name via C# and pass the name on as a parameter to populate a dropdown box or a grid view on the redirected page.

To authenticate a user I use the asp.net login control and I saw that I have access to several properties and methods but can't see text or value to just get the name back and pass it on for further processing.

Am I thinking wrong here?

Any hint on how to accomplish this is much appreciated.



how to make login control allow users to login by either username or email address


how to make login control allow users to login by either username or email address 

How to set focus to UserName textbox in Login Control ?



can you please tell how to focus cursor to UserName TextBox in Login control when page is loaded for the first time in browser ? 

How to modify the login control



I'd like to record more information than the default control allows as well as perform actions with the input when the form is submitted but I'm having trouble figuring out how.

So firstly, if I want to record the middlename for example, how would I do that, and by default, where would it go if anywhere?
When the form is submitted, I'd like to take specific input, such as just the middlename for example, and write some linq to sql code to specify when and how it's stored.
In what event would I put this code?


Composite control: How to bubble a textbox's TextChanged event?


I've created a composite control that contains several controls, including a textbox. I'm trying to expose the TextChanged event of the textbox as an event on the composite control. I understand that events can be bubbled up the control hierarchy and handled at a higher level, which I've attempted to do, but I can't get the bubbled event to fire. When I drop the control on an aspx I can see the TextChanged event, I can subscribe to the event, but nothing ever happens. Any suggestions? Here is what I think is the relevant code:

// My event
private static readonly object EventTextChanged = new object();

//Handle the bubbled event
EventHandler textChangedHandler = (EventHandler)Events[EventTextChanged];

protected override bool OnBubbleEvent(object source, EventArgs e) 
    bool handled = false;

Web Q&A: Scripting Interoperability, Login Control on a Web Farm, Custom Refreshes, App Servers, and


Knowing the event occured in user control in current page




      My web application has user control which uses third party controls called Devexpress controls. The user control is a menu  and is part of the Master page. It is placed there because this needs to be available in all the pages. My user controls raises a even on item clicked. Now, My question is that Is there any way to know that the event has occurred in page_load of the current page in which I am in?

Customize failure text for login control


Hi all,

I would like to show the failure text in a client-side alert box for login control in c#. Please help me if there is an easy way to convert it from vb.net to c#.net. Thanks a lot!

Protected Sub Login1_LoginError(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoginError
'Display the failure message in a client-side alert box
ClientScript.RegisterStartupScript(Me.GetType(), "LoginError", _
String.Format("alert('{0}');", Login1.FailureText.Replace("'", "\'")), True)

 End Sub

 Converted, but it doesn't work.

protected void Login1_LoginError(object sender, System.EventArgs e)
    //Display the failure message in a client-side alert box
    ClientScript.RegisterStartupScript(this.GetType(), "LoginError", string.Format("alert('{0}');", Login1.FailureText.Replace("'", "\\'")), true);

on click event for my control


hi ,

I have a project that when I add for example a button control I can not achieve click event ,

I can do add click event but when I add breakpoint I can not sense any response .... is there any probelem witg vs2010 ?

Login control is suddenly broken in IE7 but works perfectly on Firefox (It works on both browsers lo


Hey Guys,

 I'm new around and I thought this is probably the best place to help me solve my dilemma, I am developing a website for almost a year now and the login control was implemented a logn time ago, however all of a sudden it will not authenticate on Internet Explorer 7 when the application is published, it doesn't even provide a message that authentication was unseccssful or throws any error, it just refreshes the same page. however this problem doesn't occure when I try the same website on FireFox 2.0...Also when I run the page locally on Cassini it work great on both browsers...This is one of the weirdest errors I have ever faced. what could have gone wrong on the server side to cause this? knowing nothing changed on the server-side...I'll provide a snapshot of the login control below

<asp:Login ID="LoginControl" runat="server" BackColor="Trans

Login control not working in IE7


I spent the last few weeks getting a client site up and running, but all the while I was doing all my testing with Firefox.

I tried seeing what it would look like in IE7, and everything is great.  Except that I cannot login with it.

 I do not know for the life of me why.

Any ideas?

 I am using VWD 2008 and i have a 3.5 web.


modify login control



is it posible to change the way to log in a wss3 site.

i created a wss 3 site collection. to enter the site a login control pop up then you need to log in using windows authentication before ypu can see the site.

now i want to change this pop up thing in to a nice page. so the user can see a welcome page and there he can fill in his username and password to log in.

i want to keep using windows authentication not FBA.

is this possible?


Issue with Remember Me on User Login control


Hi everyone,

     I hope you can help me, I tried Google, but none of the solutions worked. Using VB.net and Membership, I have a login control in my master page with a remember me check box. When I check this box and login, some pages indicate that I am not logged in. If I go to another page, it will then indicate that I am still logged in. I have isolated one page that always indicates I am not logged in the first time I visit it, but if log in a second time and then go to it, it will finally recognize me as a user that is properly logged in. 

Some pages that this occurs on is in the top level, some pages are in a sub folder.

My MasterPage has the following Form Code:

<body bgcolor="#E0ECF9" topmargin="0" leftmargin="0">

    <form id="form1" runat="server">

My Aspx file has a troubleshooting label, several Gridviews and several DetailViews:

    <asp:Label ID="lblErRep" runat="server" Text=""></asp:Label>

My aspx.vb file has 1 line of code (Protec

System.Data.SqlClient.SqlException: Login failed for user . Reason: The account is disable


Hi All,

Thank you for advance.

I created a widows service for mail schedule with c#.net and sql server 2005 and it is working fine for past one year.

now sometimes i am getting the "System.Data.SqlClient.SqlException: Login failed for user '<UserName>'. Reason: The account is disabled." error.

then i restarted the windows service manually and working.

what is the problem in my sql server connection and how to fix that issue?

Binding an event method from a control in a seperate window

How would you bind a event method from a control back to a seperate window?  I have a ActiveX control hosted in a WindowsFormsIntegration wrapper.  That is operating in its own window along with all its events.  The properties of the control are handled by a class that defines the dependency objects (thanks Bob) to provide a view model between it and a window with controls for setting/getting those properties.  Since events constrained to Window 2, is it possible to bind the events back to Window 1?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend