Vivek Thangaswamy
asked on
Dynamically create ASP.NET Menu Control using C#
Dynamically create ASP.NET Menu Control and thr menu item using C# on button click
can anyone provide me code sample please
can anyone provide me code sample please
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How to set Menu.Orientation Property programmatically?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
What I'm tring to do is, On Button Click I'm Creating the Menu with three Menu Items, under that One MultiView Container and three View control inside that MultiView Container. In Each view I have added one textbox.
What i want is when i click menu item 1 it should show view 1, when click menu item 2 it should view 2,... correspondingly..
The menu item event is not firing ... Please guide me and check my code ... do i going in the right direction?
Typically wht i'm tring to do is creating Tab Control kind of display at runtime...
Please help on this.
What I'm tring to do is, On Button Click I'm Creating the Menu with three Menu Items, under that One MultiView Container and three View control inside that MultiView Container. In Each view I have added one textbox.
What i want is when i click menu item 1 it should show view 1, when click menu item 2 it should view 2,... correspondingly..
The menu item event is not firing ... Please guide me and check my code ... do i going in the right direction?
Typically wht i'm tring to do is creating Tab Control kind of display at runtime...
Please help on this.
MultiView viewContainer;
Panel Panel1 = new Panel();
protected void Button2_Click(object sender, EventArgs e)
{
Menu newMenu = new Menu();
this.form1.Controls.Add(newMenu);
MenuItem newItem1 = new MenuItem("Tab1");
newItem1.Value = "1Tab";
newMenu.Items.Add(newItem1);
MenuItem newItem2 = new MenuItem("Tab2");
newItem2.Value = "2Tab";
newMenu.Items.Add(newItem2);
MenuItem newItem3 = new MenuItem("Tab3");
newItem3.Value = "3Tab";
newMenu.Items.Add(newItem3);
newMenu.Orientation = Orientation.Horizontal;
viewContainer = new MultiView();
for (int i = 0; i < 3; i++)
{
View vw = new View();
vw.ID = "Tab" + i.ToString() + 1;
TextBox txtBox = new TextBox();
txtBox.ID = "txtBox" + vw.ID;
txtBox.Text ="View" + i.ToString();
vw.Controls.Add(txtBox);
viewContainer.Views.Add(vw);
}
viewContainer.ActiveViewIndex = 0;
Panel1.Controls.Add(viewContainer);
Page.Form.Controls.Add(Panel1);
}
protected void newMenu_MenuItemClick(Object sender, System.Web.UI.WebControls.MenuEventArgs e)
{
switch (e.Item.Value)
{
case "1Tab":
return;
case "2Tab":
return;
case "3Tab":
return;
}
}
I couldn't see this in your code; don't forget to assign your event handler to the menu.
newMenu.MenuItemClick += new MenuEventHandler(newMenu_M enuItemCli ck);
newMenu.MenuItemClick += new MenuEventHandler(newMenu_M
ASKER
After adding also its not firing ?
can you send me the code which worked for you
can you send me the code which worked for you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The following link simply says how you can dynamically create menu control.
http://msdn.microsoft.com/en-us/library/ecs0x9w5(VS.80).aspx
More just for your info, here is the link of opensource menu server control which is fully flexible and a verygood xml based menu control
http://msdn.microsoft.com/en-us/library/aa478963.aspx
HTH,