Computer Magic Logo

Wednesday, March 16, 2016

Published by Aristotelis Pitaridis

The CMUmbracoToolsRange attribute works the same way like the RangeAttribute in ASP.NET MVC. It takes three parameters. The first parameter defines the minimum value that the field can have. The second parameter defines the maximum value that the field can have. The third parameter defines the name of the dictionary which contains the error message that the system will display if the user types a value which is not in the specified numeric range.

[CMUmbracoToolsRange(10, 85, "The Age field has to be between 10 and 85.")]
public int Age { get; set; }

In order to use the CMUmbracoToolsDisplay attribute we have to define the following using.

using CMUmbracoTools.DataAnnotations;