Author: onecurlyfry | Posted on: 9/2/2009 2:24:23 PM | Views : 1133

Greetz!

I've implemented forms authentication, and realized I didn't have a logout button. So I added a lineitem in my sitemap & a new menu item, then used the following code to toggle whether "login" or "logout" is shown, based on the users .isauthenticated property: Dim menu As Menu = DirectCast(sender, System.Web.UI.WebControls.Menu) Dim menuToRemove As MenuItem = Nothing If HttpContext.Current.User.Identity.IsAuthenticated Then For Each smn As MenuItem In menu.Items If smn.Text = "Login" Then Dim parent As MenuItem = smn.Parent If Not parent Is Nothing Then parent.ChildItems.Remove(smn) Else menuToRemove = smn End If End If Next If Not menuToRemove Is Nothing Then ...

Go to the complete details ...