hi again
i have simple web form that is dependent on the login control of asp.net
here's a snapshot:
http://s279.photobucket.com/albums/kk137/wh3resmycar/?action=view¤t=login.jpg
i already have a loginview control working that says "Welcome back [user name]" ( in this case the user name is "new").
anyway, i need to get the value of the username to be inserted on to a table along with the other contact details.
i tried this method >>> "LoginView1.ClientID.ToString();"
but it didnt seem to work as i wasnt able to extract the value of the username.
// what i did was test if i can get the value and display it using a label first "Label1.Text = LoginView1.ClientID.ToString();"
didnt seem to work as the label displayed its default value.
any idea?
thanks in advance.
Loading

Kirtan PatelRank #292 · 8.6K reputationPosted Nov 14, 2009, 7:00 AM EST
you dont need to Get Value of Username From Login View as you can Get User name any time from anywere From membership class like below
string Username = User.Identity.Name;
Mark Uy130 reputationPosted Nov 14, 2009, 7:02 AM EST
Mark Uy130 reputationPosted Nov 14, 2009, 7:05 AM EST
i tried this:
string username = User.Identity.Name;
Label1.Text = username;
the label is still displaying its default values, which is "Label".
Kirtan PatelRank #292 · 8.6K reputationPosted Nov 14, 2009, 7:10 AM EST
protected void Page_Load(object sender, EventArgs e)
{
string Username = User.Identity.Name;
Label1.Text = Username;
}
verify the code one again :)
Mark Uy130 reputationPosted Nov 14, 2009, 7:11 AM EST
Mark Uy130 reputationPosted Nov 14, 2009, 7:21 AM EST
silly me i forgot that i was coding it onto another event.
thanks man.
Lalit MRank #1,186 · 1.5K reputationPosted Nov 14, 2009, 8:07 AM EST
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 = " Your account has been locked out."; } } )