I have a masterpage with a loginview, in the loginview i have an asp login control. i a
Maybe you must check if the user is authenticated or not, because the TextBox is inside the AnonymousTemplate or it's a Namespace issue(WebControls.Login):
if (!HttpContext.Current.User.Identity.IsAuthenticated) {
Login lg = (WebControls.Login)LoginView1.FindControl("Login1");
TextBox tb = (TextBox)lg.FindControl("UserName");
Label2.Text = tb.Text;
}
But normally you would get the UserName/Password via the appropriate properties UserName/Password of the Login.
Edit: Your added screenshot is very small but i see that you are getting an InvalidCastException, so my asumption on the namespace issue was correct.