CHAN Reference
Chan Home | Reference Home | Event Firing Order | web.config
Controls.DecimalBox
- Name DecimalBox
- CSS Class CC_Numeric
- Type decimal
The DecimalBox represents an input textbox which only allows a decimal value to be entered. It presents its value in code directly as a nullable decimal and has both client and server validation folded within itself.
The end result is that you can marry a DecimalBox directly to an object's decimal typed property or even directly to a database field without having to perform your own casting or validation.
Roadmap
- Handle setting of Value to DBNull directly, internally casting to Decimal? null
| Qualifiers | Type | Name | Default | Description |
|---|---|---|---|---|
| string | id | "" | Unique identifier within the page for the control | |
| string | Size | "thin" | Choice of Thin,Norm or Wide CSS sizes, corresponding to .C__Thin, .C__Norm and .C__Wide respectively | |
| bool | Enabled | true | Wether or not the control is enabled within the page, directly mapped onto the HTML input disabled property. | |
| bool | Visible | true | Wether or not the control is rendered into the output HTML stream. | |
| bool | Mandatory | false | Wether or not the control is allowed to hold an empty (null) value. | |
| decimal? | Value | (null) | The current value held by the control. | |
| decimal? | Max | (null) | The maximum value the control allows, if null it is ignored, however if the user enters a value outside the range of the decimal type it will revert the value to null | |
| decimal? | Min | (null) | The minimum value the control allows, if null it is ignored, see above regarding range. | |
| int? | Digits | (null) | The number of digits to the left of the decimal place to pad with zeros, values are allowed to exceed this unless a matching max is also set. (-1 is interpreted as NULL) | |
| int? | Places | (null) | Used to specify a fixed number of decimal places to the right of the decimal point, can be zero. Bankers rounding is used when truncating extra places. (-1 is interpreted as NULL) | |
| bool | AutoLimit | true | If this is true and the value is outside the Min/Max values it will automatically bound it instead of invalidating the control. | |
| bool | AutoZero | false | If the control is mandatory and the user enters a non-numeric value this setting will cause it to fall back to the Min value (if set) instead of invalidating the control. | |
| bool | NoScript | false | Wether or not the control is allowed to generate any javascript whatsoever. |
ASPX
<table>
<tr>
<th>Default</th>
<td><Chan:DecimalBox runat="server" value="12.34" /></td>
</tr>
<tr>
<th>Not Null</th>
<td><Chan:DecimalBox runat="server" value="12.34" mandatory="true" /></td>
</tr>
<tr>
<th>Max/Min of +/- 20, Not AutoLimited</th>
<td><Chan:DecimalBox runat="server" min="-20" max="20" value="12.34" autolimit="false" /></td>
</tr>
<tr>
<th>Three Digits and Places</th>
<td><Chan:DecimalBox runat="server" value="12.34" digits="3" places="3" /></td>
</tr>
<tr>
<th>Percentage 1dp, Mandatory and AutoZeroed</th>
<td><Chan:DecimalBox runat="server" min="0" max="100" places="1" mandatory="true" autozero="true" value="12.34" /></td>
</tr>
<tr>
<th> </th>
<td><Chan:Button runat="server" text="Validate" validateform="true" /></td>
</tr>
</table>