Dave

Dave

  • NA
  • 161
  • 0

Having trouble with Login FailureText

Apr 7 2009 10:05 PM

I have a Login control, nested in the anonymous template of a LoginView, which I have placed in a custom user control. Not a full-on server control. Just a simple Web User Control.

I have tried to write a custom FailureText message by handling the LoginError event for the Login with the following code:

        Login logCtl = ExtensionMethodHelpers.FindControlRecursive(this, "logSiteLogin") as Login;
        Literal failText = ExtensionMethodHelpers.FindControlRecursive(this, "FailureText") as Literal;
        failText.Text = "Your login attempt was not successful. Please try again.";       

        //  if the user is locked out, tell them.
        MembershipUser currentUser = Membership.GetUser(logCtl.UserName);
        if(currentUser != null)
        {
            if(currentUser.IsLockedOut)
            {
                failText.Text = "Your account has been locked due to too many invalid login " +
                    "attempts. Please contact us to have your account unlocked.";
            }
        }

This has not worked. When I debug, it moves through and assigns the "LockedOut" error message to the FailureText Literal control. But when the page comes up, the FailureText message is still just displaying the default FailureText.

Can anyone identify the problem.