Jump to content

LoginView ir buscar o username.


maxpaine

Recommended Posts

Bom Dia A todos,

Ando com um problema quase existencial, muito provavelmente por azelhice minha, estou a tentar retirar o valor de username, do campo username dentro do login view, mas sem sucesso, o codigo que ja tentei e tenho e o seguinte, tenho estado a testar esta situação dentro da Master Page directamente devido a tentar encontrar um solução funcional e depois transferir para as repectvas paginas.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
namespace WebApplication1
{
public partial class SiteMaster : System.Web.UI.MasterPage
{
 //LoginName loginName;
 protected void Page_Load(object sender, EventArgs e)
 {
	 //loginName = (LoginName)this.HeadLoginView.FindControl("HeadLoginName");

	 //TextBox password = Master.FindControl("HeadLoginView").FindControl(templa).FindControl("HeadLoginName") as TextBox;

	 //TextBox user = HeadLoginView.FindControl("HeadLoginName") as TextBox;
	 //Label1.Text = user.ToString();

	 //Label Label1 = (Label)HeadLoginView.FindControl("HeadLoginName");
	 //Label1.Text = System.Web.HttpContext.Current.User.Identity.Name;

	 //string name = (HeadLoginView.LoggedInTemplate).ToString();
	 //Label1.Text = name;

	 //var username = (LoginName)HeadLoginView.Parent.FindControl("HeadLoginName");
	 //Response.Write(username.ToString());

	 //LoginName ln = (LoginName)HeadLoginView.FindControl("HeadLoginName");

	 /*
	 LoginView lv = (LoginView)FindControl("HeadLoginView");
	 if (lv != null)
	 {
		 LoginName ln = (LoginName)lv.FindControl("HeadLoginName");
		 if (ln != null)
		 {
			 string m**** = ln.ToString();
			 Label1.Text = m****;
		 }
	 }*/
	 //LoginName UserName = (LoginName)HeadLoginView.FindControl("HeadLoginName");
	 //var Login1 = ((Login)HeadLoginView.FindControl("HeadLoginName"));

	 //var Login1 = ((LoginName)HeadLoginView.FindControl("HeadLoginName"));

	 //LoginName Login1 = ((LoginName)HeadLoginView.FindControl("HeadLoginName"));
	 //string userName = Login1.UniqueID.ToString();

	 //string Username = User.Identity.Name;
	 //Label1.Text = Username;

	 //LoginName Login1 = ((LoginName)HeadLoginView.FindControl("HeadLoginName"));
	 //string userName = Convert.ToString(Login1);

	 //Login Login1 = ((Login)HeadLoginView.FindControl("HeadLoginName"));
	 //string userName = Login1.UserName.ToString();
	 //var userName = ((Login)HeadLoginView.FindControl("HeadLoginName"));
	 //Label1.Text = Convert.ToString(userName);
	 //LoginName loginName = (LoginName)HeadLoginView.FindControl("HeadLoginName");
	 //Label1.Text = Convert.ToString(loginName);

	 //string m**** = (HttpContext.Current.User.Identity.Name);
	 //LoginName loginName = HeadLoginView.FindControl("HeadLoginName") as LoginName;
	 //Label1.Text = (loginName.ToString());
 }
 protected void HeadLoginView_ViewChanged(object sender, EventArgs e)
 {

 }

}
}

sera que existe alguma solução.

Cumprimentos

Edited by Caça
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.