Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
hi
 
I wants to develop dynamic Menu And Submenu in mysite.
Which is look like :
 
http://www.animationshops.com/[^]
 
Only Parent and related Child I want to Show.
 
So if Anybody knows then plz help me
 
Thnaks
Posted 18-Nov-12 20:43pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Create two Method one for Menu and another one for Sub-Menu both Method return string data. Menu data put in your menu control. like that see below...
Code:
string Menu(List<menuitems> menuItems)
{
    string strMenu="";
    foreach(MenuItems item in menuItems)
    {
        //It's demo menu tag, replace using your menu tag
        strMenu+="<a href=""+item.Url+"">"item.Name
        strMenu+=SubMenu(item.SubMenuItems);
        strMenu+="</a>";
    }
    return strMenu;
}
 
string SubMenu(List<submenuitems> subMenuItems)
{
    string strSubMenu="";
    foreach(SubMenuItems item in subMenuItems)
    {
        //It's demo sub-menu tag, replace using your sub-menu tag
        strSubMenu+="<a href=""+item.Url+"">"item.Name
        strSubMenu+="</a>";
    }
    return strSubMenu;
}
 
//Then in your page load event write below code...
protected void Page_Load(object sender, EventArgs e)
{
    //let divMenu your menu control or container.
    List<MenuItems> menuItems=new List<MenuItems>(); //Select menu list here...
    divMenu.innerHtml=Menu(menuItems);
}
 
Try this maybe it's work for you...
  Permalink  
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Zoltán Zörgő 220
1 Sergey Alexandrovich Kryukov 180
2 Peter Leow 160
3 BillWoodruff 85
4 bling 80
0 Sergey Alexandrovich Kryukov 9,543
1 OriginalGriff 6,901
2 Peter Leow 4,737
3 Zoltán Zörgő 4,404
4 CHill60 2,932


Advertise | Privacy | Mobile
Web04 | 2.8.150129.1 | Last Updated 20 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100