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.

Range Validation (Fixed and Dynamic)

This tutorial explains how to implement range validation in M#. We often need range validations especially on numeric values e.g. price, date etc. M# allows developers to provide a static or dynamic range for “Numeric or DateTime” type properties. In M# you can use “Lower Bound” and “Upper Bound” attributes of “Numeric” and “DateTime” type properties to specify lower and upper range respectively.

Numeric Range Validation

M# generates two levels of validation for the range provided in the screenshot below. One validation is performed in sever side and the other validation is performed on the UI by generating an ASP.NET range validator control.

The validation code below is generated in the “ValidateProperties” method of “Product” entity class.

M# also generates an ASP.NET range validator control to validate a numeric only field. This range validator does not contain dynamic ranges.

DateTime Range Validation

Date range validation is only performed in server side validation. The screenshot below shows how to specify a dynamic date for the lower bound of a “DateTime” type property in M#.