Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Dynamic login/logout button

Vote:
 

Hello!

I am new to EpiServer.

 

I am trying to write a login/logout button in the page header area template.

 

here is the header template

<asp:LoginView ID="LoginView" runat="server">
    <AnonymousTemplate>
        <a href="<%= GetLoginUrl() %>"><asp:Literal ID="Literal1" runat="server" Text="Logga in" /></a>
    </AnonymousTemplate>
    <LoggedInTemplate>
        <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutText="Logga ut" />
    </LoggedInTemplate>
</asp:LoginView>

 

I have added dynamic properties to my start page in the episerver admin CMS, "StartPage" = the start page and "LoginPage" = util/login.aspx

I get the correct printout (7 and util/login.aspx)when I write

    <%= CurrentPage["LoginPage"] %></br>
    <%= CurrentPage["StartPage"] %></br>

in the default page.

 

however I cant get the GetLoginUrl() function in the page header template background class to function as I wamt. I want to get the URL to the login page as a dynamic property.

 

for example something like this (this wont work)

 

/// <summary>
        /// Gets the link to the login page
        /// </summary>
        protected string GetLoginUrl()
        {
            PageReference loginPageRef = CurrentPage["LoginPage"] as PageReference;

            return loginPageRef.ToString();
        }

 

any ideas? :)

Thanks!

 

 

#51545
Jun 14, 2011 14:19
Vote:
 

I Think I solved it!

Changed the LoginPage dynamic property to the full URL to the login page and

protected string GetLoginUrl()
        {
            string LoginPage = CurrentPage["LoginPage"].ToString();
            return LoginPage;
        }

 

it works! However mayby there is some better solution available?

#51546
Edited, Jun 14, 2011 14:37
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.