M# Tutorials

Learn to build .NET applications with M#. Our step-by-step tutorials will get you up-to-speed rapidly.
If you already know ASP.NET and C#, you can master M# in a week or two.

Generate Links VS MenuControl

There are two different ways to generate menu items in M#, one is to generate links and the other one is a Menu control, we are going to look at the differences between them in this lesson.


For both of them we have to create a menu and add items, the only difference during the creation is that the Menu control has the attribute "Generate links" set to False.

Generated ASPX

The difference between the two is an attribute in M# UI, but the generated code is different.
Generate Links creates your menu and links in your aspx page whereas Menu control generates this "dynamically" by using an ASP.NET menu control and populated with an XML data source.

Generated C#

The generated C# code is different as well. For Generated links the selected value was set in the ASPX page, for the Menu Control this is set in the code behind in the DataBind() method. This method also calls the method GetItemsDataSource() which is the XML data source of the menu and created during the build of your page.


Be careful if you move from one type to another because that will break your CSS styles, one uses divs and the other one unordered lists.
The generated links are organized as "div.menu-module [span.selected] div.item a" whereas Menu control are as "div.menu-module div ul.level1.static li.static a.level1.item[.selected].static".
Another difference is that the Menu control contains the "role" attribute (role="menubar", role="menuitem"). Roles are important for WAI-ARIA which defines a way to make Web content and Web applications more accessible to people with disabilities.