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 markup

The View module allows you to specify some custom code to extend the default generated code. In this lesson we will not talk about common module features, you can find more details in Chapter 7 and reuse them in your Views.

Data source

As seen in the previous lesson, we can easily set the data source by passing an ID to the query string. In your view you can also specify the data source, for example

App.Context.Employee

. In your properties you can get the value of your data source by using "Item".

Header

The default header generated by M# is

Item + " details"

. Please refer to Chapter 7 to learn how to change it.

Hide empty elements

If you do not want to display labels with empty values you can set the attribute "Hide empty elements" to "True".

In our case John Smith does not have any comment, so the resulting displayed page will be:

and the mark-up:

M# displays each property only if the property has a value. This code is only generated for nullable properties because for other properties a value is mandatory so we do not need to check.

Grouping

Grouping could be essential when displaying a large amount of data. For grouping elements in your View create a "[BOX]" and name it "Address".

Now let's move all address properties to this box, set the "Box" attribute to "Address" for those properties. Those properties are now moved to the Address box.

You can also change the template of your newly created "Address" box by changing the attribute "Template".