Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
21 Points
51 Posts
Mar 25, 2008 02:11 AM|LINK
I hope you find this useful, It worked with me. Beside I didn't like this mess about .Control[0].Control[1]... this is much easier and it working perfectly.
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { Login Login1 = ((Login)LoginView1.FindControl("Login1")); string userName = Login1.UserName.ToString(); string password = Login1.Password.ToString(); if (Membership.ValidateUser(userName, password)) { if (Request.QueryString["ReturnUrl"] != null) { FormsAuthentication.RedirectFromLoginPage(userName, true); } else { FormsAuthentication.SetAuthCookie(userName, true); Response.Redirect("~/Default.aspx"); } } else { Label lblResults = (Label)Login1.FindControl("lblResults"); lblResults.Visible = true; lblResults.Text = "regarding that you have only 5 times to try"; if ((Membership.GetUser(userName) != null) && (Membership.GetUser(userName).IsLockedOut == true)) lblResults.Text = " <b>Your account has been locked out.</b>"; } }
;)
Dont forget to mark it as answer if it helps !
JustRun
Member
21 Points
51 Posts
Re: Cannot access username from LoginView > AnonymousTemplate > Login ... control.
Mar 25, 2008 02:11 AM|LINK
I hope you find this useful, It worked with me. Beside I didn't like this mess about .Control[0].Control[1]...
this is much easier and it working perfectly.
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { Login Login1 = ((Login)LoginView1.FindControl("Login1")); string userName = Login1.UserName.ToString(); string password = Login1.Password.ToString(); if (Membership.ValidateUser(userName, password)) { if (Request.QueryString["ReturnUrl"] != null) { FormsAuthentication.RedirectFromLoginPage(userName, true); } else { FormsAuthentication.SetAuthCookie(userName, true); Response.Redirect("~/Default.aspx"); } } else { Label lblResults = (Label)Login1.FindControl("lblResults"); lblResults.Visible = true; lblResults.Text = "regarding that you have only 5 times to try"; if ((Membership.GetUser(userName) != null) && (Membership.GetUser(userName).IsLockedOut == true)) lblResults.Text = " <b>Your account has been locked out.</b>"; } };)
Dont forget to mark it as answer if it helps !