you can get the user name from the System.Web.HttpContext.Current.User.Identity.Name only after the user login to the system, here is the code for you
private void btnLogin_Click(object sender, System.EventArgs e)
{
bool bResult = false;
string strUserName = txtUserName.Text.ToString();
string strPassword = txtPassword.Text.ToString();
if (Membership.ValidateUser(strUserName, strPassword))
{ // Valid User so check if they are in CRDB as well as not being disabled
MembershipUser mu = Membership.GetUser(strUserName);
e.Authenticated = true;
base.User_TpxId = Login1.UserName;
base.User_FirstName = dbUser.FirstName;
base.User_LastName = dbUser.LastName;
FormsAuthentication.RedirectFromLoginPage(Login1.UserName, false);
}
else
{
MembershipUser mu = Membership.GetUser(strUserName);
if (mu == null)
Login1.FailureText = "You do not appear to have been setup in Active Directory. Please contact an Administrator";
else
Login1.FailureText = "Your password does not appear to be correct.";
e.Authenticated = false;
}
}