maxpaine Posted August 23, 2012 at 08:12 AM Report Share #473216 Posted August 23, 2012 at 08:12 AM (edited) 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 August 23, 2012 at 08:16 AM by Caça Link to comment Share on other sites More sharing options...
andreia Posted August 23, 2012 at 08:15 AM Report Share #473217 Posted August 23, 2012 at 08:15 AM Não sei se resolve o seu problema. Eu utilizo desta forma: Dim Utilizador As String = Page.User.Identity.Name Link to comment Share on other sites More sharing options...
maxpaine Posted August 23, 2012 at 08:31 AM Author Report Share #473218 Posted August 23, 2012 at 08:31 AM nada feito recebo um null exeption Link to comment Share on other sites More sharing options...
rumbafum Posted August 23, 2012 at 09:04 AM Report Share #473219 Posted August 23, 2012 at 09:04 AM Queres aceder ao username em que altura? Em que evento? Geralmente pelo sender de eventos como o LoggedIn consegues obter essa informação facilmente. Caso contrário tens que iterar pela colecção de controlos de LoginView para encontrar a textbox que pretendes Link to comment Share on other sites More sharing options...
maxpaine Posted August 23, 2012 at 09:16 AM Author Report Share #473220 Posted August 23, 2012 at 09:16 AM (edited) basicamente estou a usar a standard que veio com o wizard, é na altura que se muda ou actualiza de pagina. Edited August 23, 2012 at 09:18 AM by maxpaine Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now