Hello!
I'm working with the RadMaskedNumericInput for the
first time (first time using masked inputs at all) and am in need of
advice. I want to have the control's value be set to a default value if
the user were to clear the control's input, then remove the focus.
I have the control set up like so:
<telerik:RadMaskedNumericInput x:Name="txtDaysValid" Width="30" Value="30"
Mask="d2" TextMode="PlainText" InputBehavior="Insert"
maskedInput:MaskedInputExtensions.Minimum="1"
UpdateValueEvent="LostFocus"
LostFocus="txtDaysValid_LostFocus"/>
And the event handler is:
var numericInput = sender as RadMaskedNumericInput;
if (string.IsNullOrWhiteSpace(numericInput.Text))
{
numericInput.Value = 30;
numericInput.Text = numericInput.Value.ToString();
}
This is the behaviour I'm currently experiencing:
- Control Reads 30 -> User sets blank -> Control Reads blank (incorrect)
- Control Reads 30 -> User sets to 12 -> Control Reads 12 -> User sets blank -> Control reads 30 (correct)
- Control Reads 30 -> User sets to 12 -> Control Reads 12 -> User sets blank -> Control reads 30 -> User sets blank -> Control reads blank (incorrect)
- Control Reads Blank -> User sets to 1 -> Control Reads 1 -> User sets blank -> Control Reads blank (incorrect)
- Control Reads Blank -> User sets to 21 -> Control Reads 21 -> User sets blank -> Control Reads 30 (correct)
What am I missing here? It appears that updating the value and text directly only works in some cases. Is there a better approach to ensuring that when the user clears the input's field, that it defaults to a specific value upon losing focus?
Thanks!