Computer Magic Logo

Wednesday, March 16, 2016

Published by Aristotelis Pitaridis

The CMUmbracoToolsStringLength attribute works the same way like the StringLengthAttribute in ASP.NET MVC. It takes two parameters. The first parameter defines the maximum number of characters that can be typed for the specified field. The second parameter defines the name of the dictionary which contains the error message that the system will display if the user types more than the defined number of characters.

[CMUmbracoToolsStringLength(20, "The Name field cannot have more than 20 characterls length.")]
public string Name { get; set; }

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

using CMUmbracoTools.DataAnnotations;