How to create and use menu in ASP.NET?

To be frank I used to think that ASP.NET menu control was complex and hard to use. Boy was I wrong!!!

ASP.NET provides a menu control which allows you set all its visual properties and menu items and voila start using them. Not only that you can create a theme for it and with a bit of imagination you can have a snazzy looking menu ready for you in a couple of minutes.

Below is the code for a simple horizontal view menu. You can use it to enhance its look and feel.

<asp:Menu ID=”mnu” runat=”server”
DisappearAfter=”500″ MaximumDynamicDisplayLevels=”5″
<DynamicMenuItemStyle Font-Names=”Arial” Font-Size=”Small” BackColor=”#f7f7f7″ Width=”200″ />
<DynamicHoverStyle BackColor=”#ffff00″ />
<StaticMenuItemStyle BackColor=”#f7f7f7″ Font-Names=”Arial” Font-Size=”Small” />
<asp:MenuItem Text=”About Us” NavigateUrl=”about_us.aspx”>
<asp:MenuItem Text=”Company” NavigateUrl=”company.aspx”></asp:MenuItem>
<asp:MenuItem Text=”Our Goal” NavigateUrl=”goals.aspx”></asp:MenuItem>
<asp:MenuItem Text=”Company” NavigateUrl=”company.aspx”></asp:MenuItem>
<asp:MenuItem Text=”Products” NavigateUrl=”products.aspx”>
<asp:MenuItem Text=”Product Catalog” NavigateUrl=”catalog.aspx”></asp:MenuItem>
<asp:MenuItem Text=”Enquiry” NavigateUrl=”enquiry.aspx”></asp:MenuItem>

Hope the above helps

Leave a Comment