Solved

dynamic menu in asp.net c#

Posted on 2016-11-18
11
26 Views
Last Modified: 2016-11-21
i am trying to build  dynamic menu in asp.net as example in below URL

http://www.aspsnippets.com/Articles/Bootstrap-Responsive-ASPNet-Menu-control-for-Mobile-Phone-Tablet-and-Desktop-display.aspx

only one menu option is showing dropdown menu and not other menu options.

I need help on above url code to make other menu option with dropdown .




Thanks in advance.
0
Comment
Question by:rnsr
  • 6
  • 5
11 Comments
 
LVL 17

Expert Comment

by:Pawan Kumar Khowal
ID: 41892741
thats because the entries in the DB are missing. Add below entries in your table.

INSERT INTO tableName VALUES
(7,1,'Pawan','Pawan','~/Pawan.aspx'),
(8,1,'Pawan1','Pawan1','~/Pawan1.aspx.')

Open in new window


Hope it helps !
0
 

Author Comment

by:rnsr
ID: 41892747
table entries are as example below  -

id       parentid    name     desc         url

1         0                a              aa         '~/Pawan.aspx'
2         0                b               bb         '~/Pawan1.aspx'
3         1                c                cc          '~/Pawan2.aspx'
4         1                d                dd         '~/Pawan3.aspx'
5         2                e                ee          '~/Pawa5.aspx'
0
 
LVL 17

Expert Comment

by:Pawan Kumar Khowal
ID: 41892749
So for these entries , what you are not getting ?
0
 

Author Comment

by:rnsr
ID: 41892754
a and b are main menu options.

 on click ' a' option i want to get drop down menu with option 'c' and 'd'
on click 'b' option i want to get drop down menu with option 'e'
0
 
LVL 17

Accepted Solution

by:
Pawan Kumar Khowal earned 500 total points
ID: 41892799
Change this in main.master...

<script type="text/javascript">
        //Disable the default MouseOver functionality of ASP.Net Menu control.
        Sys.WebForms.Menu._elementObjectMapper.getMappedObject = function () {
            return false;
        };
        $(function () {
            //Remove the style attributes.
            $(".navbar-nav li, .navbar-nav a, .navbar-nav ul").removeAttr('style');

            //Apply the Bootstrap class to the SubMenu.
            $(".dropdown-menu").closest("li").removeClass().addClass("dropdown-toggle");

            //Apply the Bootstrap properties to the SubMenu.
            //$(".dropdown-toggle:has(ul)").find("a").eq(0).attr("data-toggle", "dropdown").attr("aria-haspopup", "true").attr("aria-expanded", "false").append("<span class='caret'></span>");
            $(".dropdown-toggle").each(function (index) {
                if ($(this).children('ul').length > 0) {
                    $(this).find("a").eq(0).attr("data-toggle", "dropdown").attr("aria-haspopup", "true").attr("aria-expanded", "false").append("<span class='caret'></span>");
                }
            });
            //Apply the Bootstrap "active" class to the selected Menu item.
            $("a.selected").closest("li").addClass("active");
            $("a.selected").closest(".dropdown-toggle").addClass("active");
        });
    </script>

Open in new window


Output
-----------------

EE
Hope it helps !
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:rnsr
ID: 41895373
Hi,
   i placed this code but on wrong position in my code.

Thanks,
0
 

Author Comment

by:rnsr
ID: 41895438
unable to show drop down menu when page  is loaded. it shows dropdown menu when one of the main menu option is clicked.

Any solution.
0
 
LVL 17

Expert Comment

by:Pawan Kumar Khowal
ID: 41895448
Can you please provide the screen shot?
0
 

Author Comment

by:rnsr
ID: 41895475
attached image.

first time when page is loaded it shows drop down button but when clicked on it  no dropdown menu is shown. when i click on
add sub category then it will show all options of  drop down menu.

Plaese help.
newty.png
0
 
LVL 17

Expert Comment

by:Pawan Kumar Khowal
ID: 41895483
I think that is the correct process. When you click on the menu item it should show sub menu items.
0
 

Author Comment

by:rnsr
ID: 41895494
It doesn't show drop down when first time clicked on it after page is loaded. if i click on other option and then click on drop down menu , then it shows drop down options.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now