ASP.NET 2.0: asp:Login and OnLoggingIn

R

R.A.M.

I have a problem with logging in implementation in ASP.NET 2.0.
I decided to use asp:Login control (which is enough), but I cannot
find solution for handling logging in.
I have an .aspx:

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="DefaultPage" %>
....
<form id="LoginForm" method="post" action="Menu.aspx"
style="vertical-align: middle;" runat="server">
<asp:Login ID="DemoLogin" runat="server"
DestinationPageUrl="Menu.aspx"
TitleText="Logowanie"
UserName="demo" UserNameLabelText="U¿ytkownik"
PasswordLabelText="Has³o"
PasswordRequiredErrorMessage="Wymagane has³o."
LoginButtonText="Zaloguj" LoginButtonType="Button"
RememberMeSet="true" RememberMeText="Zapamiêtaj"
InstructionText="Wprowad¼: demo/demo."
OnLoggingIn="OnLogginIn"
VisibleWhenLoggedIn="false" />
</form>
....

in behind-code I wrote:

....
public partial class DefaultPage : System.Web.UI.Page
{
public void OnLoggingIn(object sender,
System.Web.UI.WebControls.LoginCancelEventArgs e)
{
if (DemoLogin.UserName == "demo" &&
DemoLogin.Password == "demo")
DemoLogin.InstructionText = String.Empty;
else
{
DemoLogin.InstructionText = "Failure. Enter: demo/demo.";
e.Cancel = true;
}
}
}

But when trying to build the application I receive error:

ASP.default.aspx does not contain a definition for 'OnLogginIn"

I do not understand this message.
I tried to move OnLogginIn function to .aspx:

<script runat="server">...</script>

but I cannot build, either.
Could you help me please?
Thank you!!!
/RAM/
 
K

Ken Cox - Microsoft MVP

Looks like a typo. In one case you've got the function named

OnLoggingIn

But the login control is told to use

OnLogginIn (missing the 'g')

Ken
 
R

R.A.M.

Looks like a typo. In one case you've got the function named
OnLoggingIn
But the login control is told to use
OnLogginIn (missing the 'g')

Thanks, I corrected. But I don't know why my login doesn't work as I
expected. After entering demo/demo I receive red message:

"Your login attempt was not successful. Please try again"

1. Did I miss something?
2. How to set the red message text? (I prefer Polish language.)
Could you help me please?
Thank you!
/RAM/
 
E

Erik Funkenbusch

Thanks, I corrected. But I don't know why my login doesn't work as I
expected. After entering demo/demo I receive red message:

"Your login attempt was not successful. Please try again"

1. Did I miss something?
2. How to set the red message text? (I prefer Polish language.)

Add FailureText = "your message in polish" to the DemoLogin control's
attributes. You don't have to handle OnLoggingIn at all if you want to
give the standard error message if they've entered something else.
 
R

R.A.M.

On Sun, 19 Mar 2006 09:07:56 -0600, Erik Funkenbusch

Thank you! (I added FailureText.)
I still do not understand why red message is displayed although
OnLoggingIn() passes successfully. Does anybody know?
Thank you for help - I am beginner.
/RAM/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top