The following numeric types are handled by this component:
- Integer
- Decimal
- Currency
- Slider
The Numeric component is used to display an integer, double, currency or slider to users. The different numeric types are displayed as options when creating the field, the default display type being integer.
Component Code
The first section of the code for the component contains the standard parameter set along with the variables needed for the component to function. Following the variables are the methods used by the component which are listed below.
OnParametersSetAsync()
This method is called after the component initializes and when there’s an update to the parent component. Its purpose is to assign values to variables
ValueChanged()
This method is called when the value of the numeric field has changed. This method ensures the field is modifiable and if so validates the input. If the input is valid then the ChangeXML method is called, otherwise nothing happens.
ChangeXML()
This method is used to update the XML of the instance to reflect the value of the numeric field. When called the required XML is generated, the element name is equal to the XMLName variable, and the current value of the field represented as the ValueUX variable.
Lastly, a call is made to the ChangeField method on myInstance and the new XML is passed. If auto postback is enabled, it will also save the current instance and reload it.
Below is an example of the XML structure to be saved:
<NumericEx>5</NumericEx>
If unit specification is enabled and for example the selected unit is “cm”, the saved XML structure will be:
<NumericEx Unit="cm">5</NumericEx>