Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript ASP:NET
Hi all I have one ASP Menu in which it has some menu items. See below code
 
 <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
                    <items>
                        <asp:MenuItem NavigateUrl="~/Home.aspx" Text="Home"/>
                        <asp:MenuItem NavigateUrl="~/AboutUs.aspx" Text="About"/>
                         <asp:MenuItem NavigateUrl="~/Admin.aspx" Text="Admin"/>
                         <asp:MenuItem NavigateUrl="~/UserAccount.aspx" Text="User"/> 
                    </items>

I want to hide or disable 3rd menu item based on login session. I know how to handle session but I am not right with how to hide one asp:menu item. I can't apply CSS to single Menu Item.
So friends Please tell me what to do
Posted 30-Sep-12 21:01pm
Ganeshcse2.4K
Edited 2-Oct-12 23:19pm
DaveAuld181.3K
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim whologged As String
        whologged = HttpContext.Current.User.Identity.Name
        If whologged <> "admin" Then
            TopMenu.Items.RemoveAt(2)
        End If
 
End Sub
 
Just got this working, couldn't find this no where on the internet. Hope it works for you.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 275
2 ProgramFOX 265
3 Maciej Los 245
4 Andreas Gieriet 200
0 OriginalGriff 465
1 Sergey Alexandrovich Kryukov 275
2 ProgramFOX 265
3 Maciej Los 245
4 Andreas Gieriet 200


Advertise | Privacy | Mobile
Web02 | 2.8.150331.1 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100