Search code examples
c#asp.netaspmenu

dynamicaly add menu itmes to asp:Menu


I have a defined asp:Menu in design time in the master page.

I want to in the master page code behind in the page-load event a check that if the user is in the developer role, then they will get an additional set of menu items.

how do i use c# to add menu items from the code behind to the asp:menu?

i am not using a site map provider!


Solution

  • place this in your code behind:

    Menu1.Items.Add(new MenuItem("Text", "Value"));