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.

Custom selected value

M# tries to select the current menu item whenever it is possible, but for some cases you will generate this dynamically, having the same redirection URL but with a different query string, and then you will have to set this manually.

Static items

Creation

To make things simple we will create a menu with two items redirecting the Employee page, but with a different name set in the query string.

If we display the page our two menu items will be selected because the target page is the same (only the query string changed).

Change selection

To avoid the selection problem we have to set a unique key for each item.

If this key is the result of the function FindSelectedValue() this item will be selected.
Now you have to overwrite the default code of this function, to do this set the "Selected item value" attribute of the menu to

return "Employee" + Request["Name"];

.
You may also want to use the attribute "Special selected key role", it allows you to specify a rule at the beginning of the FindSelectedValue() function.

Dynamic items

Please refer to the lesson Dynamic menu items for more details on the implementation.