<asp:Menu id="NavigationMenu" Runat="Server" Orientation="Horizontal" StaticMenuStyle-VerticalPadding="2" StaticMenuItemStyle-Font-Name="Verdana" StaticMenuItemStyle-Font-Size="9pt" StaticMenuItemStyle-ForeColor="white" StaticHoverStyle-BackColor="#707070" StaticHoverStyle-ForeColor="white" StaticSelectedStyle-Font-Bold="True" StaticSelectedStyle-BackColor="black" StaticSelectedStyle-ForeColor="RED"> <items> <asp:MenuItem Text="Home" NavigateUrl="Home.aspx" > <asp:MenuItem Text="Admin" NavigateUrl="A.aspx"> <asp:MenuItem Text="B" NavigateUrl="B.aspx"> <asp:MenuItem Text="C" NavigateUrl="C.aspx"> </items>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load '-- Get page name from relative path Dim ThisPage As String = Page.AppRelativeVirtualPath Dim SlashPos As Integer = InStrRev(ThisPage, "/") Dim PageName As String = Right(ThisPage, Len(ThisPage) - SlashPos) '-- Select menu item with matching NavigateUrl property Dim ParentMenu As MenuItem Dim ChildMenu As MenuItem For Each ParentMenu In NavigationMenu.Items If ParentMenu.NavigateUrl = PageName Then ParentMenu.Selected = True Else For Each ChildMenu In ParentMenu.ChildItems If ChildMenu.NavigateUrl = PageName Then ChildMenu.Selected = True End If Next End If Next If Not IsPostBack Then StrQry = "" StrQry = " Select isnull(A,'') as Admin,isnull(Home,'') as Home," StrQry &= " isnull(B,'') as B,isnull(C,'') as C"" Conn.Open() Cmd.Connection = Conn Cmd.CommandText = StrQry Rdr = Cmd.ExecuteReader If Rdr.HasRows Then While Rdr.Read 'Here I need to display the Menu if record is there..... End While End If Rdr.Close() Conn.Close() End If 'check whether session expires End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)