User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 427,939 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,815 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 962 | Replies: 2 | Solved
Reply
Join Date: Apr 2008
Posts: 19
Reputation: Nithya.G is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
Nithya.G's Avatar
Nithya.G Nithya.G is offline Offline
Newbie Poster

dynamic menu

  #1  
Jun 16th, 2008
how to create dynamic menu using c# in asp .net. i need with codings.. or with example.

Thanx in advance
Nithya
Nithya
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Location: Somewhere between heaven and hell
Posts: 101
Reputation: Kusno is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
Kusno's Avatar
Kusno Kusno is offline Offline
Junior Poster

Re: dynamic menu

  #2  
Jul 11th, 2008
Hi Nithya. G,

I use EssentialObject menu control to create dynamic menu.

Sub CreateMenu()
        Dim MI As EO.Web.MenuItem
        Dim MII As EO.Web.MenuItem
        Dim MIII As EO.Web.MenuItem
        Dim Add As Boolean

        MyMenu.Items.Clear()
        MyMenu.EnableScrolling = True
        MyMenu.EnableViewState = False 
        MyMenu.ScrollDownLookID = "scroll_down"
        MyMenu.ScrollUpLookID = "scroll_up"
        MyMenu.ScrollSpeed = 100 

        Dim SQL As String
        Dim I As SByte = 0

        Dim CnMenu As New SqlClient.SqlConnection
        Dim CnSubMenu As New SqlClient.SqlConnection
        Dim CnFunction As New SqlClient.SqlConnection

        SQL = "Select MasterMainMenu.MainMenuID, MasterMainMenu.MainMenuName, MainMenuLink from MasterMainMenu order by Seq "
        GetCN(CnMenu)

        Dim CmMenu As New SqlClient.SqlCommand(SQL, CnMenu)
        Dim RdMenu As SqlClient.SqlDataReader
        RdMenu = CmMenu.ExecuteReader()
        Do While RdMenu.Read
            MI = New EO.Web.MenuItem
            MI.ItemID = RdMenu.Item("MainMenuID").ToString.Trim
            MI.Text.Html = RdMenu.Item("MainMenuName").ToString.Trim
            If RdMenu.Item("MainMenuLink").ToString.Trim <> "" Then MI.NavigateUrl = RdMenu.Item("MainMenuLink").ToString.Trim

            MI.HoverStyle.Font.Size = 8
            MI.HoverStyle.Font.Bold = True
            MI.NormalStyle.Font.Bold = True
            MI.NormalStyle.Font.Size = 8
            MI.HoverStyle.ForeColor = Drawing.Color.RoyalBlue
            MyMenu.Items.Add(MI)

            SQL = "Select FunctionID, SubMainMenuName, SubMainMenuID, FunctionLink from MasterSubMainMenu where MainMenuID='" & RdMenu.Item("MainMenuID").ToString.Trim & "' Order By Seq"
            GetCN(CnSubMenu)
            Dim CmSubMenu As New SqlCommand(SQL, CnSubMenu)
            Dim RdSubMenu As SqlClient.SqlDataReader
            RdSubMenu = CmSubMenu.ExecuteReader
            Do While RdSubMenu.Read
                MII = New EO.Web.MenuItem
                MII.ItemID = RdSubMenu.Item("SubMainMenuID").ToString.Trim
                MII.HoverStyle.ForeColor = Drawing.Color.Red
             
                MII.HoverStyle.Font.Size = 8
                MII.HoverStyle.Font.Bold = True
                MII.NormalStyle.Font.Bold = True
                MII.NormalStyle.Font.Size = 8
                MII.Text.Html = RdSubMenu.Item("SubMainMenuName").ToString.Trim

                If SetStringValue(RdSubMenu.Item("FunctionLink")) <> "" Then
                    If Security.IsUserAllowed(Session("UserId"), SetStringValue(RdSubMenu.Item("FunctionID")), UserAccess.CanDisplay) = True Then
                        MII.NavigateUrl = RdSubMenu.Item("FunctionLink").ToString.Trim
                        MII.Status = RdSubMenu.Item("FunctionLink").ToString.Trim
                        Add = True
                    End If
                Else
                    SQL = "Select MasterFunction.FunctionID,MasterFunction.FunctionName,FunctionLink, FunctionTarget from MasterUserFunctionDetail inner join MasterFunction On MasterFunction.FunctionID=MasterUserFunctionDetail.FunctionID where MasterUserFunctionDetail.UserID='" & Trim(Session("UserID")) & "' and MasterFunction.MainMenuID='" & SetStringValue(RdSubMenu.Item("SubMainMenuID")) & "' and ISNULL(DISABLED,'') = 'N' Order By MasterFunction.Seq "
                    GetCN(CnFunction) 

                    Dim CmFunction As New SqlCommand(SQL, CnFunction)
                    Dim RdFunction As SqlClient.SqlDataReader
                    RdFunction = CmFunction.ExecuteReader 
                    If RdFunction.HasRows = False Then
                        Add = False
                    Else
                        Do While RdFunction.Read
                            If Security.IsUserAllowed(Session("UserId"), RdFunction.Item("FunctionId").ToString.Trim, UserAccess.CanDisplay) = True Then
                                MIII = New EO.Web.MenuItem
                                MIII.ItemID = RdFunction.Item("FunctionId").ToString.Trim
                                MIII.HoverStyle.Font.Size = 8
                                MIII.HoverStyle.Font.Bold = True
                                MIII.HoverStyle.ForeColor = Drawing.Color.Red
                       
                                MIII.NormalStyle.Font.Bold = True
                                MIII.NormalStyle.Font.Size = 8
                                MIII.NavigateUrl = RdFunction.Item("FunctionLink").ToString.Trim
                                MIII.Status = RdFunction.Item("FunctionLink").ToString.Trim
                                MIII.Text.Html = RdFunction.Item("FunctionName").ToString.Trim
                                MIII.TargetWindow = RdFunction.Item("FunctionTarget").ToString.Trim
                                MII.SubMenu.Items.Add(MIII)
                            End If
                        Loop
                        Add = True
                    End If
                    SetToNothing(CnFunction, RdFunction, CmFunction)
                End If
                If Add = True Then MyMenu.Items(I).SubMenu.Items.Add(MII)
            Loop
            I = I + 1 
            SetToNothing(CnSubMenu, RdSubMenu, CmSubMenu)
        Loop
        SetToNothing(CnMenu, RdMenu, CmMenu)
    End Sub

Thanks,

Kusno.
NEVER NEVER NEVER GIVE UP
Reply With Quote  
Join Date: Apr 2008
Posts: 19
Reputation: Nithya.G is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
Nithya.G's Avatar
Nithya.G Nithya.G is offline Offline
Newbie Poster

Re: dynamic menu

  #3  
Jul 12th, 2008
thank u so much...
Nithya
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 6:35 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC