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.

Search Elements

For any page which contains large amount of records, it becomes necessary to let users filter the records using search criteria. In this lesson, we will take a look at the search functionality provided in M# and how we can utilize it.

M# provides search functionality on list modules and is managed in a separate section inside the module. M# generates all the search fields / criteria inside one container called “SearchBox” which is placed right after the module heading.

M# search functionality is very flexible as it generates the search controls and criteria not only based on the underlying “Entity” properties but also allows implementing custom controls and criteria. The screenshot below shows the search management section and available elements

The inset highlighted elements shown in above screenshot are the properties of the Entity (Employee), selected at the time of creating the list module (For more information on creating modules, please read lesson “Entities, Page, Module” in chapter 1). The other elements shown in the popup menu are used for custom criteria and customization of search box layout.


The “Box” element shown in the screenshot above is a container element, used to customize the layout of the search elements. This box has same usage as the module box (For more information of boxes please read lesson Module Boxes in chapter 7).

All Fields

This search element is used to implement text based search. M# generates a text box on the UI for this purpose and performs a text search on the string representation of each record. M# generates the Search button which contains the default actions, as shown below

The C# generated code in the screenshots above has a method “ToSTring(“F”)” underlined. This is an overridden ToString(format) method which is implemented in Business Logic to return a string comprising of the selected property values, as shown below

List Elements Search Fields

In M# you can use the properties of the list module entity as the search criteria. M# allows you select the search fields you require, as shown below

M# generates related ASP.NET input controls on the UI (In above case a textbox for email field and a dropdown list for Status, as status field is one to many relationship). M# also generates default criteria to search the records based on the input fields, as shown below:

As shown in the screenshot above, a new method “AddSearchFilters()” is generated, which defines the filter criteria for each element we have used. These filters are then applied in GetBaseDataSource() method, retrieved by calling “GetFilters()” method, as shown in below