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.

Module properties

In this lesson we will have a look at the module properties available under the "Code" heading of each module. M# provides different types of properties including all the entities available in the model. This helps maintaining readable and compact code and effectively saving time by just writing the getter or setter of a property.

Creating a Property

By focusing inside the properties section, M# displays a list of all the object (custom and entity) types which can be used as the return type of a property. You can also type the required "Type" to filter down the list shown below

Important: M# encourages developers to create properties to be used in UI related requirements, rather than hardcoding in different places e.g. as DataSource for controls or modules.

In order to create a property, you need to select the required property type (return type) and need to provide a "Name" of the property.

In the above screenshot, we have created a property "HelloWorld" by selecting String as the "Custom Type (return type)" of the property and a name "HelloWorld".

M# generates a public property in the code behind class of our module which is shown in the screenshot below:

Property Attributes

M# provides different attributes, which can be used to further customize the property as required e.g. getter, setter, caching etc. We will go through each attribute and will apply them on our previously created "HelloWorld" property.


This attribute is used to implement the "Getter" of a property, as shown below:


This is the name of the property, which is used to call the property from elsewhere in your code.

Cache Value

This attribute is very important as it affects the performance of the module. It is used to decide whether to cache the returned object. M# declares a CachedValue⩽type> private variable, which is populated and retuned in the "Getter" of the property. M# repopulates the private variable when it gets null during postbacks. The default value of this attribute is false.

Query String Key

This attribute is used to retrieve a value from the QueryString. M# encourages using this attribute when you want to get some value from the QueryString. You just need to specify the "Key" of the QueryString and M# generates the code to retrieve the value. This attribute replaces the "Getter" attribute.


This attribute is simply used to remove the property from the generated code when selected value is "True".

Entity Type

This attribute lets developer to use the Entity Type defined in the Model as the return type of the property.

Custom Type

This attribute is used to specify a return type other than the defined Entity Types.

Important: The properties described above, "Entity Type" and "Custom Type", are mutually exclusive and are used to change the return type of a property.