Tuesday, December 30, 2008

How To Create Menu Dynamically With Child Elements

protected void Page_Load(object sender,  EventArgs e)
{

Menu
myMenu = new Menu();
this.form1.Controls.Add(myMenu);
MenuItem mnItem = new MenuItem("Dyamnic Menu");
myMenu.Items.Add(mnItem);


MenuItem menuNodeChild = new MenuItem("Xploredotnet");
mnItem.ChildItems.Add(menuNodeChild);
menuNodeChild.NavigateUrl =
"http://www.Xploredotnet.com";
menuNodeChild = new
MenuItem("ASP.NET");
mnItem.ChildItems.Add(menuNodeChild);
menuNodeChild.NavigateUrl =
"http://www.asp.net";


myMenu.Orientation =
Orientation.Horizontal;
//myMenu .Orientation = Orientation.Vertical;
}

No comments: