Menu visiblity in vb.net RRS feed

  • Question

  • User-1578974752 posted

    I have a menu. In that 1 item I want to show only if the Manager Login?

    How to  make it possible. Thanks

    Monday, December 9, 2019 6:48 AM


  • User288213138 posted

    Hi shsu,


    I have a menu. In that 1 item I want to show only if the Manager Login?

    According to your description,  are you using the menu control in asp.net?  if so, I made demo for you as a reference. you can use the Items.Remove() method to remove the item.

      name:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
                password:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
                <asp:Button ID="Button1" runat="server" Text="Login" OnClick="Button1_Click" /><br /><br />
                 <asp:Menu ID="Menu1" Orientation="Vertical" runat="server" Visible="false" >
                        <asp:MenuItem Text="Home" ToolTip="Home">
                            <asp:MenuItem Text="Music" ToolTip="Music"></asp:MenuItem>
                            <asp:MenuItem Text="Movies" ToolTip="Movies"></asp:MenuItem>
                        <asp:MenuItem Text="Home1" ToolTip="Home1">
                            <asp:MenuItem Text="Book" ToolTip="Book"></asp:MenuItem>
                            <asp:MenuItem Text="Game" ToolTip="Game"></asp:MenuItem>
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        If TextBox1.Text = "Manager" AndAlso TextBox2.Text = "123" Then
            Menu1.Visible = True
            Dim menuItems As MenuItemCollection = Menu1.Items
            Dim adminItem As MenuItem = New MenuItem()
            For Each menuItem As MenuItem In menuItems
                If menuItem.Text = "Home1" Then
                    adminItem = menuItem
                End If
            Menu1.Visible = True
        End If
    End Sub

    Best regards,


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 10, 2019 3:36 AM