Exemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            var membershipUser = Membership.GetUser();

            if (membershipUser != null)
            {
                this.UserName = membershipUser.UserName.Replace(Sitecore.Context.Domain.Name + @"\", string.Empty);
            }

            var isLoggedIn = MainUtil.IsLoggedIn();

            this.liStatusNotLoggedIn.Visible = !isLoggedIn;
            this.liStatusLoggedIn.Visible    = isLoggedIn;
            this.liMypage.Visible            = isLoggedIn;
            this.btnLogIn.Visible            = !isLoggedIn;
            this.btnLogOut.Visible           = isLoggedIn;

            GeneralSettings generalSettings = Sitecore.Ecommerce.Context.Entity.GetConfiguration <GeneralSettings>();

            this.btnLogIn.HRef = ItemUtil.GetItemUrl(generalSettings.MainLoginLink, true);

            this.lblLogedInAs.Text = string.Format(Translate.Text(Sitecore.Ecommerce.Examples.Texts.YouAreLoggedInAs), this.UserName);
        }