Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

1 solution

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:
C#
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...
 
Share this answer
 
v4

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900