OnLoggingIn Custom Method
By Nannette Thacker
When you use the Login control in the toolbox, it generates
code that looks like this:
<asp:Login ID="Login1" runat="server">
</asp:Login>
And from design view, it looks something like this (depending
on your background):
When a user then uses the log in control to log into the site,
ASP.NET sends them to the ValidateUser function in the MembershipProvider
class.
But what if you want to run your own custom code
prior to validating the user? You can add your own "OnLoggingIn"
method.
Microsoft provides more information on the
OnLoggingIn Method and explains that
it "Raises the LoggingIn event when a user submits login information
but before the authentication takes place." See this article
on the
Login.LoggingIn Event also. Both articles
have some examples of this in use. You might
also want to see the Login Control Events section of the
ASP.NET Page Life Cycle Overview document.
So in effect, if you are using a Login control and you want
to run your custom log in code before the system handles the
log in, you may use the "OnLoggingIn" property to access your
custom function.
<asp:Login ID="Login2" runat="server"
OnLoggingIn="Login1_LoggingIn">
</asp:Login>
Notice I simply added this property to the log in control:
OnLoggingIn="Login1_LoggingIn"
You'll put your Login1_LoggingIn method in your code behind:
Protected Sub Login1_LoggingIn(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs)
' pre log in code goes here
End Sub
Nannette
"No power in the verse can stop me." - River, Firefly