使用Javascript隐藏

使用Javascript隐藏

本文介绍了使用Javascript隐藏/禁用ASP菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我有一个ASP菜单,里面有一些菜单项。见下面的代码



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>







我想基于登录会话隐藏或禁用第3个菜单项。我知道如何处理会话,但我不知道如何隐藏一个asp:菜单项。我不能将CSS应用于单个菜单项。

所以朋友请告诉我该怎么做




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

推荐答案

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.


这篇关于使用Javascript隐藏/禁用ASP菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 04:04