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.

Mandatory Property VS Form Level Mandatory

In this tutorial we will discuss the difference between a property marked as mandatory in the model and as form input control on UI.

Mandtaory Property

M# entity properties can be marked as mandatory, which represents Database Table “Allow Nulls” design time column. When a property is marked as mandatory, M# un-marks the “Allow Nulls” column in the database, generates a validation rule in Model entity class and an input validation control on the UI form, which validates the required field on client side (For more information on making mandatory properties, please read tutorial Properties in chapter 2).

Form Level Manadtory

Form level mandatory property controls the mandatory rule on the UI level by adding or removing ASP.NET validator control associated to the property input control.

Important: Changing the mandatory rule of a property on UI doesn’t affect the Business Logic validation. It only applies validation on the Front End e.g. if you mark a property as mandatory in Model but change that to not mandatory on the UI, it will not validate it on the client side but a validation message will be thrown from the server side model validation.