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.

Page Settings

This lesson talks about page level settings in M#. In this lesson we will see how we can utilise page settings to control content and the look and feel of a page. Page settings are created and managed in M# Project settings (For more information on Managing Page Settings, please read tutorial Page Settings in chapter 13).

Implementing Page Settings

M# provides a separate section on pages, where you can implement page settings. In this lesson we will use the "LeftMenu" page setting defined by M# and will see how M# utilizes the page settings. The screenshot below shows the page settings section of employee page

The above screenshot shows the section "Settings", which displays all the defined page setting keys. When we implement any page setting, M# modifies the sitemap of the website for that specific page as shown below:

"TopMenu and LeftMenu" page settings requires "Menu Module" name in camel case without any spaces, as highlighted in above screenshot, (Menu Modules are discussed in another lesson). Page settings can contain any value e.g. bool, int or string etc. but M# stores the page setting as the description of the sitemap node as highlighted below.

Page Settings utilization in M#

M# offers an extension method "GetSetting" on SiteMapNode type object which is used to read the page setting from Sitemap of the website. M# provides two overloads of this method as described below:

The method shown above requires the key of the page setting e.g. LeftMenu, TopMenu etc. and returns the value if defined else returns empty string.

The overload shown above requires on extra parameter of "bool" type which is used determined if key search should include inherited settings.

In our lesson we have used LeftMenu page setting to display the "Employee left menu module" as the left menu for the current page and all subpages. This key is utilized in the "Side bar" module and master page to display left menus. M# creates some default modules for each M# project, which are copied in master page mark-up.(For more information on those modules please read lesson Modal VS Standard in chapter 6).

Side bar module reads LeftMenu page setting and loads the specified menu module for each page (As in our lesson "EmployeeLeftMenu"). Master page also uses LeftMenu page setting to show or hide the side bar module. The screenshots below show the utilization of LeftMenu page settings:

The code shown above reads the LeftMenu page setting and loads the specified module.