The number editor renders a control for setting numeric values. The number editor only accepts digits and a decimal separator. The number editor can optionally be prefixed with a label.
The number editor is the default editor for numeric property types, f.e. int
, long
, decimal
and double
. The number editor may also be used for a string property type, as long as the string value can be parsed to a numeric value.
Usage
The number editor is the default editor for numeric properties. You can set additional configuration through the NumberEditorAttribute
.
Decimals
You can set the number of decimal places that can be edited for the property value through the Decimals
property of the NumberEditorAttribute
. This only applies to decimal or floating-point property types.
Prefix
You can set a prefix label for the editor through the Prefix
property of the NumberEditorAttribute
. A prefix label is rendered to the left side of the input field and can provide additional information about the intended use of the property to the user. This can also be done by decorating the same property with the Prefix attribute.
Example
public class SampleContent: IContentType
{
// Renders a number editor by convention.
public int MaxItems { get; set; }
// Specifies a currency numeric editor.
[NumberEditor(Decimals = 2, Prefix = "EUR")]
public decimal DailyRate { get; set; }
// ...
}