Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Guys I have this code:

<div class="float-right">
                    <section id="login">
                        <asp:LoginView runat="server" ViewStateMode="Disabled">
                            <AnonymousTemplate>
                                <ul>
                                    <li><a id="loginLink"  runat="server" href="~/Account/Login">Log in</a></li>
                                </ul>
                            </AnonymousTemplate>
                            <LoggedInTemplate>
                                <p>
                                    Hello, 
                                    <asp:LoginName runat="server" CssClass="UserName" />
                                    !
                                <asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/Account/Login.aspx" />
                                </p>
                            </LoggedInTemplate>
                        </asp:LoginView>
                    </section>
                    <nav>
                        <ul id="menu">
                            <li><a  runat="server" href="~/">Home</a></li>
                            <li><a  runat="server" href="TF_new.aspx">Schedule Trip</a></li>
                            <li><a  runat="server" href="~/About">Help</a></li>
                        </ul>
                    </nav>
                </div>
            </div>
        </header>
        <div id="body">
            <asp:ContentPlaceHolder runat="server" ID="FeaturedContent" />
            <section class="content-wrapper main-content clear-fix">
                <asp:ContentPlaceHolder runat="server" ID="MainContent" />
            </section>
        </div>


And i want to hide the Home page from users that are not logged in... how do I do it?
I know that if I put it inside the Anonymous Template it will be hidden but I wanted to do it without moving it since I want to do this to several others things
Posted

1 solution

change your home link as below
ASP.NET
<li id="homeItem" runat="server" ><a  runat="server" href="~/">Home</a></li>

in page load method do as below
C#
homeItem.Visible = HttpContext.Current.User.Identity.IsAuthenticated;
 
Share this answer
 
Comments
varmartins 21-Jan-15 12:06pm    
Thanks mate, that worked ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900