Partager via


Creating a Menu in ASP.NET

After spending some time wondering how to create an effective menu I stumbled accross the System.Web.UI.WebControls Menu Class, It was really easy to implement, in your aspx file you just write some code that looks like this:

<asp:Menu ID="myMenu" runat="server" orientation="Vertical">
    <Items>
        <asp:MenuItem Text="This is a menu Item 1" />
        <asp:MenuItem Text="This is a menu Item 2" />
        <asp:MenuItem Text="This is a menu Item 3" />
    </Items>
</asp:Menu>

And there you have it a simple Menu control out of the box that you can sit on any aspx page. It's also worth mentioning that it has loads of styles you can add to it as well. To read up more have a look at:

https://msdn2.microsoft.com/en-gb/library/system.web.ui.webcontrols.menu.aspx